average of the values, must have more than 0 entries.

  :param arr: list of numbers
  :type arr: number[] a number array
  :return: average
  :rtype: float
199614
def average(arr):
  
  if len(arr) == 0:
    sys.stderr.write("ERROR: no content in array to take average\n")
    sys.exit()
  if len(arr) == 1:  return arr[0]
  return float(sum(arr))/float(len(arr))
1170911
def averagingData(array, windowSize=None, averagingType='median'):
    
    assert averagingType in ['median', 'mean']
    if windowSize is None:
        windowSize = int(len(array) / 50) if int(len(array) / 50) > 100 else 100

    if averagingType == 'median':
        averagedData = runningMedian(array, windowSize)
    elif averagingType == 'mean':
        averagedData = runningMean(array, len(array), windowSize)
    return averagedData
524576
def average():
    
    count = 0
    total = total()
    i=0
    while 1:
        i = yield ((total.send(i)*1.0)/count if count else 0)
        count += 1
486679
private function scoresToFloat(array $arr)
    {
        foreach ($arr as $member => $score) {
            $arr[$member] = (float) $score;
        }

        return $arr;
    }
62745
function (arr) {
		var res = [];
		for (var i = 0; i < arr.length; i++) {
			res[i] = this._v(arr[i]);
		}
		return res;
	}
155634
function(arr) {
        for (var i = 0; i < arr.length; i++) {
          var randIndex = Math.floor(Math.random() * arr.length);
          var temp = arr[randIndex];
          arr[randIndex] = arr[i];
          arr[i] = temp;
        }
        return arr;
      }
953771
def median(self, default=None):
        
        return numpy.asscalar(numpy.median(self.values)) if self.values else default
1311489
def geomean(array):
    
    n = len(array)

    if n < 1:
        return 0
    elif n == 1:
        return array[0]
    return stats.mstats.gmean(array)
434025
def _averageFromList(self, param):
        
        _result = 0.0
        _count = 0

        for _param in param.split(','):
            if _param != '' and float(_param) != 0.0:
                _result = _result + float(_param)
                _count  += 1

        if _count >= 1:
            _result = _result / _count
        return _result
221018
def weighted_average(rule, artifact):
    
    e = 0
    w = 0
    for i in range(len(rule.R)):
        r = rule.R[i](artifact)
        if r is not None:
            e += r * rule.W[i]
            w += abs(rule.W[i])
    if w == 0.0:
        return 0.0
    return e / w
899174
public static function average(array $array, int $decimals = 0)
    {
        $count = Arr::size($array);

        if ( ! $count) {
            return 0;
        }

        if ( ! is_int($decimals)) {
            $decimals = 0;
        }

        return round(array_sum($array) / $count, $decimals);
    }
527030
public static int[] sort(double[] arr) {
        int[] order = new int[arr.length];
        for (int i = 0; i < order.length; i++) {
            order[i] = i;
        }
        sort(arr, order);
        return order;
    }
493766
def limiter(arr):
    
    dyn_range = 32767.0 / 32767.0
    lim_thresh = 30000.0 / 32767.0
    lim_range = dyn_range - lim_thresh

    new_arr = arr.copy()

    inds = N.where(arr > lim_thresh)[0]

    new_arr[inds] = (new_arr[inds] - lim_thresh) / lim_range
    new_arr[inds] = (N.arctan(new_arr[inds]) * 2.0 / N.pi) *\
        lim_range + lim_thresh

    inds = N.where(arr < -lim_thresh)[0]

    new_arr[inds] = -(new_arr[inds] + lim_thresh) / lim_range
    new_arr[inds] = -(
        N.arctan(new_arr[inds]) * 2.0 / N.pi * lim_range + lim_thresh)

    return new_arr
766865
public static long numVectors(INDArray arr) {
        if (arr.rank() == 1)
            return 1;
        else if (arr.rank() == 2)
            return arr.size(0);
        else {
            int prod = 1;
            for (int i = 0; i < arr.rank() - 1; i++) {
                prod *= arr.size(i);
            }

            return prod;
        }
    }
1106459
def maximum_variation(arr):
  '''
  
  '''
  return np.max(arr, axis=0) - np.min(arr, axis=0)
25547
function float32 (arr) {
	if (arr.length) {
		if (arr instanceof Float32Array) return arr
		var float = new Float32Array(arr)
		float.set(arr)
		return float
	}

	// number
	narr[0] = arr
	return narr[0]
}
279712
function quantiles( arr, num, opts ) {
	if ( !Array.isArray( arr ) ) {
		throw new TypeError( 'quantiles()::invalid input argument. First argument must be an array.' );
	}
	if ( !isInteger( num ) || num <= 0 ) {
		throw new TypeError( 'quantiles()::invalid input argument. Second argument must be a positive integer.' );
	}
	if ( arguments.length > 2 ) {
		if ( !isObject( opts ) ) {
			throw new TypeError( 'quantiles()::invalid input argument. Options should be an object.' );
		}
		if ( opts.hasOwnProperty( 'sorted' ) && typeof opts.sorted !== 'boolean' ) {
			throw new TypeError( 'quantiles()::invalid input argument. Sorted flag must be a boolean.' );
		}
		if ( opts.hasOwnProperty( 'method' ) && typeof opts.method !== 'string' ) {
			throw new TypeError( 'quantiles()::invalid input argument. Method must be a string.' );
		}
		// TODO: validate that the requested method is supported. list.indexOf( method )
	} else {
		opts = {};
	}
	var len = arr.length,
		qValues = new Array( num+1 ),
		id,
		val;

	if ( !opts.sorted ) {
		arr = arr.slice();
		arr.sort( ascending );
	}

	// 0th quantile is the min:
	qValues[ 0 ] = arr[ 0 ];

	// Max defines the quantile upper bound:
	qValues[ num ] = arr[ len-1 ];

	// Get the quantiles...
	for ( var i = 1; i < num; i++ ) {

		// Calculate the vector index marking the quantile:
		id = ( len * i / num ) - 1;

		// Is the index an integer?
		if ( id === Math.floor( id ) ) {
			// Value is the average between the value at id and id+1:
			val = ( arr[ id ] + arr[ id+1 ] ) / 2.0;
		} else {
			// Round up to the next index:
			id = Math.ceil( id );
			val = arr[ id ];
		}
		qValues[ i ] = val;
	} // end FOR i
	return qValues;
}