Return the mean value of a list of divisible numbers.
332407
def mean(array):
    
    n = len(array)

    if n < 1:
        return 0
    elif n == 1:
        return array[0]
    return sum(array) / n
393032
def samplevar(inlist):
    
    n = len(inlist)
    mn = mean(inlist)
    deviations = []
    for item in inlist:
        deviations.append(item - mn)
    return ss(deviations) / float(n)
406294
def calculate_median(given_list):
        
        median = None

        if not given_list:
            return median

        given_list = sorted(given_list)
        list_length = len(given_list)

        if list_length % 2:
            median = given_list[int(list_length / 2)]
        else:
            median = (given_list[int(list_length / 2)] + given_list[int(list_length / 2) - 1]) / 2.0

        return median
968195
def average_points_dist(p0, p_list):
    
    return np.mean(list(point_dist(p0, p1) for p1 in p_list))
678750
def calc_deviation(values, average):
    
    size = len(values)
    if size < 2:
        return 0
    calc_sum = 0.0

    for number in range(0, size):
        calc_sum += math.sqrt((values[number] - average) ** 2)
    return math.sqrt((1.0 / (size - 1)) * (calc_sum / size))
604480
def get_mean(data_np):
    
    i = np.isfinite(data_np)
    if not np.any(i):
        return np.nan
    return np.mean(data_np[i])
1105626
def counter_mean_and_median(counter):
    
    if not counter:
        return np.nan, np.nan

    total = sum(v for k, v in counter.items())
    mid = total / 2
    weighted_sum = 0
    items_seen = 0
    median_found = False
    for k, v in sorted(counter.items()):
        weighted_sum += k * v
        items_seen += v
        if not median_found and items_seen >= mid:
            median = k
            median_found = True
    mean = weighted_sum * 1. / total
    return mean, median
949899
def count_above_mean(x):
    
    m = np.mean(x)
    return np.where(x > m)[0].size
319121
public static double Skewness(int[] values, double mean, double stdDeviation){
        double n = 0;
        for (int i = 0; i < values.length; i++)
            n += values[i];
        
        double part1 = n / (n - 1) * (n - 2);
        
        double part2 = 0;
        for (int i = 0; i < values.length; i++) {
            part2 += Math.pow((i - mean) / stdDeviation, 3) * values[i];
        }
        
        return part1 * part2;
    }
551997
def mean_field(self):
        """"""
        mean_field = []
        for sp_oper in [self.oper['O'], self.oper['O_d']]:
            avgO = np.array([self.expected(op) for op in sp_oper])
            avgO[abs(avgO) < 1e-10] = 0.
            mean_field.append(avgO*self.param['ekin'])

        return np.array(mean_field)
1024687
def var(inlist):
    
    n = len(inlist)
    mn = mean(inlist)
    deviations = [0] * len(inlist)
    for i in range(len(inlist)):
        deviations[i] = inlist[i] - mn
    return ss(deviations) / float(n - 1)
957565
def variance(array):
    
    if len(array) < 2:
        return 0
    u = mean(array)
    return sum([(x - u) ** 2 for x in array]) / (len(array) - 1)
551440
def median(data):
    """"""
    data.sort()
    num_values = len(data)
    half = num_values // 2
    if num_values % 2:
        return data[half]
    return 0.5 * (data[half-1] + data[half])
375910
public static double stddev(Collection<? extends Number> values) {
        double mean = mean(values);
        double sum = 0d;
        for (Number n : values) {
            double d = n.doubleValue() - mean;
            sum += d*d;
        }
        return Math.sqrt(sum / values.size());
    }
1200056
def pairwise_mean(values):
    ""
    return numpy.array([numpy.mean(pair) for pair in pairwise(values)])
1048746
def _values(self):
        """"""
        return [
            val[1] for serie in self.series for val in
            (serie.interpolated if self.interpolate else serie.points)
            if val[1] is not None and (not self.logarithmic or val[1] > 0)
        ]
307853
private double sumSquaredDiffs()
    {        
        double mean = getArithmeticMean();
        double squaredDiffs = 0;
        for (int i = 0; i < getSize(); i++)
        {
            double diff = mean - dataSet[i];
            squaredDiffs += (diff * diff);
        }
        return squaredDiffs;
    }