Compute the mean across records
549469
def mean(self):
        
        return self._constructor(self.values.mean(axis=self.baseaxes, keepdims=True))
949899
def count_above_mean(x):
    
    m = np.mean(x)
    return np.where(x > m)[0].size
1146165
def compute_balance_mean_ts(self, ts):
        
        balance = [self.compute_balance_mean(ts, t) for t in np.arange(0, len(ts) - 1)]
        return balance
193656
def Mean(self):
    """"""
    values = [v for v, _ in self.data if v is not None]
    if not values:
      return None

    # TODO(hanuszczak): Why do we return a floored division result instead of
    # the exact value?
    return sum(values) // len(values)
1260699
def mean(name, num, minimum=0, maximum=0, ref=None):
    '''
    
    '''
    return calc(
        name=name,
        num=num,
        oper='mean',
        minimum=minimum,
        maximum=maximum,
        ref=ref
    )
374914
def mean(self):
        
        if self._can_use_new_school():
            self._prep_spark_sql_groupby()
            import pyspark.sql.functions as func
            return self._use_aggregation(func.mean)
        self._prep_pandas_groupby()
        return DataFrame.fromDataFrameRDD(
            self._regroup_mergedRDD().values().map(
                lambda x: x.mean()), self.sql_ctx)
696331
def _compute_mean(self, C, mag, dists, rake):
        
        mean = (
            C['a1'] +
            self._compute_linear_magnitude_term(C, mag) +
            self._compute_quadratic_magnitude_term(C, mag) +
            self._compute_logarithmic_distance_term(C, mag, dists) +
            self._compute_faulting_style_term(C, rake)
        )

        return mean
858220
def mean(data):
    """"""
    #: http://stackoverflow.com/a/27758326
    n = len(data)
    if n < 1:
        raise ValueError('mean requires at least one data point')
    return sum(data)/n
1278566
def get_mean_and_std(dataset):
    """"""
    dataloader = torch.utils.data.DataLoader(
        dataset, batch_size=1, shuffle=True, num_workers=2
    )
    mean = torch.zeros(3)
    std = torch.zeros(3)
    print("==> Computing mean and std..")
    for inputs, _ in dataloader:
        for i in range(3):
            mean[i] += inputs[:, i, :, :].mean()
            std[i] += inputs[:, i, :, :].std()
    mean.div_(len(dataset))
    std.div_(len(dataset))
    return mean, std
981445
def insert_size_stats(dists):
    
    med = numpy.median(dists)
    filter_dists = list(filter(lambda x: x < med + 10 * med, dists))
    median = numpy.median(filter_dists)
    return {"mean": float(numpy.mean(filter_dists)), "std": float(numpy.std(filter_dists)),
            "median": float(median),
            "mad": float(numpy.median([abs(x - median) for x in filter_dists]))}
607393
def _compute_mean(self, C, mag, rhypo, hypo_depth, mean, idx):
        
        mean[idx] = (C['C1'] + C['C2'] * mag + C['C3'] * np.log(rhypo[idx] +
                     C['C4'] * np.exp(C['C5'] * mag)) + C['C6'] * hypo_depth)
744035
def predict(self, record):
        
        
        # Get raw predictions.
        # {tree:raw prediction}
        predictions = {}
        for tree in self.trees:
            _p = tree.predict(record)
            if _p is None:
                continue
            if isinstance(_p, CDist):
                if _p.mean is None:
                    continue
            elif isinstance(_p, DDist):
                if not _p.count:
                    continue
            predictions[tree] = _p
        if not predictions:
            return

        # Normalize weights and aggregate final prediction.
        weights = self.weighting_method(predictions.keys())
        if not weights:
            return
#        assert sum(weights) == 1.0, "Sum of weights must equal 1."
        if self.data.is_continuous_class:
            # Merge continuous class predictions.
            total = sum(w*predictions[tree].mean for w, tree in weights)
        else:
            # Merge discrete class predictions.
            total = DDist()
            for weight, tree in weights:
                prediction = predictions[tree]
                for cls_value, cls_prob in prediction.probs:
                    total.add(cls_value, cls_prob*weight)
        
        return total
1200056
def pairwise_mean(values):
    ""
    return numpy.array([numpy.mean(pair) for pair in pairwise(values)])
763647
def get_average_record(self, n):
        
        history_deque = collections.deque()
        averages = []
        for d in self.data_points:
            history_deque.appendleft(d)
            if len(history_deque) > n:
                history_deque.pop()
            avg = sum(history_deque) / len(history_deque)
            averages.append(round(avg, self.lr))
        return averages
476169
def eval_mean(self, func, args=()):
        """"""
        self.fmean = func(self.mean, *args)
        return self.fmean
655214
def estimate_column_means(
            self,
            X,
            observed,
            row_means,
            row_scales):
        
        n_rows, n_cols = X.shape
        row_means = np.asarray(row_means)

        if len(row_means) != n_rows:
            raise ValueError("Expected length %d but got shape %s" % (
                n_rows, row_means.shape))
        column_means = np.zeros(n_cols, dtype=X.dtype)

        X = X - row_means.reshape((n_rows, 1))
        row_weights = 1.0 / row_scales
        X *= row_weights.reshape((n_rows, 1))
        col_residual_sums = np.nansum(X, axis=0)
        for j in range(n_cols):
            col_mask = observed[:, j]
            sum_weights = row_weights[col_mask].sum()
            column_means[j] = col_residual_sums[j] / sum_weights
        return column_means
708026
def _compute_mean(self, C, g, mag, hypo_depth, rrup, vs30, pga_rock, imt):
        
        if hypo_depth > 100:
            hypo_depth = 100
        delta = 0.00724 * 10 ** (0.507 * mag)
        R = np.sqrt(rrup ** 2 + delta ** 2)

        s_amp = self._compute_soil_amplification(C, vs30, pga_rock, imt)

        mean = (
            # 1st term
            C['c1'] + C['c2'] * mag +
            # 2nd term
            C['c3'] * hypo_depth +
            # 3rd term
            C['c4'] * R -
            # 4th term
            g * np.log10(R) +
            # 5th, 6th and 7th terms
            s_amp
        )

        return mean