Aggragation for calculate mean and std.
162472
def aggregated_relevant_items(raw_df):
    
    df = (
        raw_df[['idSegmento', 'idPlanilhaItens', 'VlUnitarioAprovado']]
        .groupby(by=['idSegmento', 'idPlanilhaItens'])
        .agg([np.mean, lambda x: np.std(x, ddof=0)])
    )
    df.columns = df.columns.droplevel(0)
    return (
        df
        .rename(columns={'<lambda>': 'std'})
    )
215923
def mean(self):
    """"""
    if len(self) == 0:
      return float('NaN')
    arr = self.samples()
    return sum(arr) / float(len(arr))
150041
function aggregate (weights, values) {
  const max = 10 * R.sum(weights);
  const min = 1 * R.sum(weights);
  const sum = R.sum(R.zipWith(R.multiply, weights, values));
  return score(min, max, sum);
}
1091478
def std(expr, **kw):
    

    ddof = kw.get('ddof', kw.get('_ddof', 1))

    output_type = _stats_type(expr)
    return _reduction(expr, Std, output_type, _ddof=ddof)
974265
def _compute_mean(self, C, mag, rrup):
        
        mean = (C['c1'] +
                self._compute_term1(C, mag) +
                self._compute_term2(C, mag, rrup) +
                self._compute_term3(C, rrup))
        return mean
1144288
def _mean_absolute_error(y, y_pred, w):
    """"""
    return np.average(np.abs(y_pred - y), weights=w)
1198801
def get_cusum(self, mag):
        

        c = np.cumsum(mag - self.weighted_mean) / len(mag) / self.weighted_std

        return np.max(c) - np.min(c)
150342
def mad(v):
    
    return np.median(np.abs(v - np.median(v)))
166322
def compute_avg_adj_deg(G):
    
    """
    return np.sum(np.dot(G.A, G.A), axis=1) / (np.sum(G.A, axis=1) + 1.)
630918
def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types):
        

        COEFFS = self.COEFFS[imt]
        R = self._compute_term_r(COEFFS, rup.mag, dists.rrup)

        mean = 10 ** (self._compute_mean(COEFFS, rup.mag, R))

        # Convert units to g,
        # but only for PGA and SA (not PGV):
        if imt.name in "SA PGA":
            mean = np.log(mean / (g*100.))
        else:
            # PGV:
            mean = np.log(mean)

        c1_rrup = _compute_C1_term(COEFFS, dists.rrup)
        log_phi_ss = 1.00

        stddevs = self._get_stddevs(
            COEFFS, stddev_types, sites.vs30.shape[0], rup.mag, c1_rrup,
            log_phi_ss, COEFFS['mean_phi_ss']
        )

        return mean, stddevs
190198
function SNV(data) {
    var mean = Stat.mean(data);
    var std = Stat.standardDeviation(data);
    var result = data.slice();
    for (var i = 0; i < data.length; i++) {
        result[i] = (result[i] - mean) / std;
    }
    return result;
}
748089
def mean(self):
        """"""
        _self = self._discard_value(None)
        if not _self.total():
            return None
        weighted_sum = sum(
            key * value for key, value in iteritems(_self)
        )
        return weighted_sum / float(_self.total())
495713
def AVEDEV(Series, N):
    
    return Series.rolling(N).apply(lambda x: (np.abs(x - x.mean())).mean(), raw=True)
1234163
def mad(self,x, axis=None):
        """"""
        return np.median(np.abs(x - np.median(x, axis)), axis)
1070657
def stddev(values, meanval=None):  #from AI: A Modern Appproach
    """"""
    if meanval == None: meanval = mean(values)
    return math.sqrt( sum([(x - meanval)**2 for x in values]) / (len(values)-1) )
1038909
public static /*@pure@*/ double mean(double[] vector) {
  
    double sum = 0;

    if (vector.length == 0) {
      return 0;
    }
    for (int i = 0; i < vector.length; i++) {
      sum += vector[i];
    }
    return sum / (double) vector.length;
  }
1138665
def _compute_ymean(self, **kwargs):
        """"""
        y = np.asarray(kwargs.get('y', self.y))
        dy = np.asarray(kwargs.get('dy', self.dy))

        if dy.size == 1:
            return np.mean(y)
        else:
            return np.average(y, weights=1 / dy ** 2)