Computes the median absolute deviation of *data* along a given *axis*.
    See `link <https://en.wikipedia.org/wiki/Median_absolute_deviation>`_ for
    details.

    **Parameters**

    data : array-like

    **Returns**

    mad : number or array-like
186161
def mad(data, axis=None):
    
    return median(absolute(data - median(data, axis)), axis)
955496
def mad(arr, relative=True):
    
    with warnings.catch_warnings():
        warnings.simplefilter("ignore")
        med = np.nanmedian(arr, axis=1)
        mad = np.nanmedian(np.abs(arr - med[:, np.newaxis]), axis=1)
        if relative:
            return mad / med
        else:
            return mad
446359
def median(array):
    
    n = len(array)

    if n < 1:
        return 0
    elif n == 1:
        return array[0]

    sorted_vals = sorted(array)
    midpoint = int(n / 2)
    if n % 2 == 1:
        return sorted_vals[midpoint]
    else:
        return (sorted_vals[midpoint - 1] + sorted_vals[midpoint]) / 2.0
1191318
def agg_dims(arr, stat):
    
    axis = None
    if arr.ndim > 2:
        axis = 1
        arr = arr.reshape(arr.shape[0], -1)
    module = np.ma if hasattr(arr, 'mask') else np
    return getattr(module, stat)(arr, axis)
332407
def mean(array):
    
    n = len(array)

    if n < 1:
        return 0
    elif n == 1:
        return array[0]
    return sum(array) / n
550452
def get_median(data_np):
    """"""
    i = np.isfinite(data_np)
    if not np.any(i):
        return np.nan
    return np.median(data_np[i])
68637
function median( out, x ) {
	var len = x.length,
		i;
	if ( out.length !== len ) {
		throw new Error( 'median()::invalid input arguments. Input and output matrices must be the same length.' );
	}
	for ( i = 0; i < len; i++ ) {
		out.data[ i ] = MEDIAN( x.data[ i ] );
	}
	return out;
}
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
1031322
def stats(name, array, *extras):
    
    std = numpy.nan if len(array) == 1 else numpy.std(array, ddof=1)
    return (name, numpy.mean(array), std,
            numpy.min(array), numpy.max(array), len(array)) + extras
185454
def centroid(data, method=median):
    ""
    out = []
    for i in range(len(data[0])):
        out.append(method([x[i] for x in data]))
    return tuple(out)
883858
def kurtosis(data):
    

    if not data:
        raise StatisticsError('kurtosis requires at least one data point')

    size = len(data)
    sd = stdev(data) ** 4

    if not sd:
        return 0.0

    mn = mean(data)
    return sum(map(lambda x: ((x - mn) ** 4 / sd), data)) / size - 3
1069444
def outlier_cutoff(a, threshold=3.5):
    
    A = np.array(a, dtype=float)
    M = np.median(A)
    D = np.absolute(A - M)
    MAD = np.median(D)
    C = threshold / .67449 * MAD
    return M - C, M + C
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
1156416
public static function mad(array $values, ?float $median = null) : float
    {
        $median = $median ?? self::median($values);

        $deviations = [];

        foreach ($values as $value) {
            $deviations[] = abs($value - $median);
        }

        return self::median($deviations);
    }
953771
def median(self, default=None):
        
        return numpy.asscalar(numpy.median(self.values)) if self.values else default
203517
def median_interval(data, alpha=_alpha):
    
    q = [100*alpha/2., 50, 100*(1-alpha/2.)]
    lo,med,hi = np.percentile(data,q)
    return interval(med,lo,hi)