Current method is to compute average from all intervals.
961672
def compute_treshold_interval(self):
        

        intervals = [m.interval for m in self.modules if hasattr(m, "interval")]
        if len(intervals) > 0:
            self.treshold_interval = round(sum(intervals) / len(intervals))
278413
def _compute(self):
        
        for serie in self.series:
            serie.points, serie.outliers = \
                self._box_points(serie.values, self.box_mode)

        self._x_pos = [(i + .5) / self._order for i in range(self._order)]

        if self._min:
            self._box.ymin = min(self._min, self.zero)
        if self._max:
            self._box.ymax = max(self._max, self.zero)
1358651
def avg(self, property):
        
        self.__prepare()
        return self.sum(property) / self.count()
1202298
def calculated_intervals(self, intervals):
        
        if len(intervals) > 1:
            raise ValueError("Only single calculated interval valid for AssetStream")
        super(AssetStream, self.__class__).calculated_intervals.fset(self, intervals)
853904
public static double[] averageSmooth( double[] values, int lookAhead ) throws Exception {
        int size = values.length;
        double[] newValues = new double[values.length];
        for( int i = 0; i < lookAhead; i++ ) {
            newValues[i] = values[i];
        }
        for( int i = lookAhead; i < size - lookAhead; i++ ) {
            double sum = 0.0;
            int k = 0;
            for( int l = -lookAhead; l <= lookAhead; l++ ) {
                double value = values[i + l];
                if (!isNovalue(value)) {
                    sum = sum + value;
                    k++;
                }
            }
            newValues[i] = sum / k;
        }
        for( int i = size - lookAhead; i < size; i++ ) {
            newValues[i] = values[i];
        }
        return newValues;
    }
32002
def average(self):
        ""
        result = DefaultBunch(str)

        #  if possible
        if self.size:
            result.update(
                (key, '' if isinstance(val, basestring) else val / self.size)
                for key, val in self.total.items()
            )

        # Handle time fields
        #for key, fielddef in  engine.FieldDefinition.FIELDS.items():
        #    if key in result and fielddef._matcher is matching.TimeFilter:
        #       result[key] = ''
        #for key, fielddef in  engine.FieldDefinition.FIELDS.items():
        #    if key in result and fielddef._matcher is matching.TimeFilter:
        #        result[key] = engine._fmt_duration(result[key])
        #print self.total
        #print result
        return result
65289
def variance(arr):
  
  avg = average(arr)
  return sum([(float(x)-avg)**2 for x in arr])/float(len(arr)-1)
282277
def _compute(self):
        """"""
        if self.xvals:
            if self.xrange:
                x_adapter = reduce(compose, self._x_adapters) if getattr(
                    self, '_x_adapters', None
                ) else ident

                xmin = x_adapter(self.xrange[0])
                xmax = x_adapter(self.xrange[1])

            else:
                xmin = min(self.xvals)
                xmax = max(self.xvals)
            xrng = (xmax - xmin)
        else:
            xrng = None

        if self.yvals:
            ymin = self._min
            ymax = self._max

            if self.include_x_axis:
                ymin = min(ymin or 0, 0)
                ymax = max(ymax or 0, 0)

            yrng = (ymax - ymin)
        else:
            yrng = None

        for serie in self.all_series:
            serie.points = serie.values
            if self.interpolate:
                vals = list(
                    zip(
                        *sorted(
                            filter(lambda t: None not in t, serie.points),
                            key=lambda x: x[0]
                        )
                    )
                )
                serie.interpolated = self._interpolate(vals[0], vals[1])

        if self.interpolate:
            self.xvals = [
                val[0] for serie in self.all_series
                for val in serie.interpolated
            ]
            self.yvals = [
                val[1] for serie in self.series for val in serie.interpolated
            ]
            if self.xvals:
                xmin = min(self.xvals)
                xmax = max(self.xvals)
                xrng = (xmax - xmin)
            else:
                xrng = None

        # these values can also be 0 (zero), so testing explicitly for None
        if xrng is not None:
            self._box.xmin, self._box.xmax = xmin, xmax

        if yrng is not None:
            self._box.ymin, self._box.ymax = ymin, ymax
1286950
def avg(self, func=lambda x: x):
        
        count = self.count()
        if count == 0:
            raise NoElementsError(u"Iterable contains no elements")
        return float(self.sum(func)) / float(count)
1050681
def edge_average(a):
    ""

    if len(np.ravel(a)) < 2:
        return float(a[0])
    else:
        top_edge = a[0]
        bottom_edge = a[-1]
        left_edge = a[1:-1,0]
        right_edge = a[1:-1,-1]

        edge_sum = np.sum(top_edge) + np.sum(bottom_edge) + np.sum(left_edge) + np.sum(right_edge)
        num_values = len(top_edge)+len(bottom_edge)+len(left_edge)+len(right_edge)

        return float(edge_sum)/num_values
320294
def tick_all(self, times):
        

        for i in range(times):
            for avg in (self.m1, self.m5, self.m15, self.day):
                avg.tick()
401869
function average(array) {
  var length = array.length;

  if (length === 0) {
    throw new RangeError("Error");
  }

  var index = -1;
  var result = 0;

  while (++index < length) {
    result += array[index];
  }

  return result / length;
}
682201
def compute(self):
        """"""
        self._compute_primary_smooths()
        self._smooth_the_residuals()
        self._select_best_smooth_at_each_point()
        self._enhance_bass()
        self._smooth_best_span_estimates()
        self._apply_best_spans_to_primaries()
        self._smooth_interpolated_smooth()
        self._store_unsorted_results(self.smooth_result, numpy.zeros(len(self.smooth_result)))
905781
def _compute(self, data):
        """"""
        local_ts = self._local_ts(*data)
        dt = local_ts[internal_names.TIME_WEIGHTS_STR]
        # Convert dt to units of days to prevent overflow
        dt = dt / np.timedelta64(1, 'D')
        return local_ts, dt
795567
def calculate_averages(results)
      Array.new(results.first.size) do |require_number|
        samples = results.map { |r| r[require_number] }
        first_sample = samples.first

        average = initialize_average_with_copied_fields(first_sample)
        AVERAGED_FIELDS.map do |field|
          next unless first_sample.key?(field)

          average[field] = calculate_average(samples.map { |s| s[field] })
        end
        average
      end
    end
1264353
def calculate_intervals(chunk_sizes):
        
        start_indexes = [sum(chunk_sizes[:i]) for i in range(0, len(chunk_sizes))]
        end_indexes = [sum(chunk_sizes[:i+1]) for i in range(0, len(chunk_sizes))]
        return tuple(zip(start_indexes, end_indexes))
281814
def triangular_moving_average(data, period):
    
    catch_errors.check_for_period_error(data, period)

    tma = sma(sma(data, period), period)
    return tma