Harmonic mean of an array, returns the closest int
962260
def hmean_int(a, a_min=5778, a_max=1149851):
    
    from scipy.stats import hmean
    return int(round(hmean(np.clip(a, a_min, a_max))))
401869
function average(array) {
  var length = array.length;

  if (length === 0) {
    throw new RangeError("Error");
  }

  var index = -1;
  var result = 0;

  while (++index < length) {
    result += array[index];
  }

  return result / length;
}
639633
def min(self):
        
        return round(np.min(self.array), self.precision)\
            if len(self.array) else None
1332953
public static int min(IntArrayND array)
    {
        return array.stream().parallel().reduce(
            Integer.MAX_VALUE, Math::min);
    }
390538
public int getMinValueIndex(double[] array) {

        int index = 0;
        double min = Integer.MAX_VALUE;

        for (int i = 0; i < array.length; i++) {
            if (array[i] < min) {
                min = array[i];
                index = i;
            }
        }

        return index;
    }
379393
def _gauss(mean: int, sigma: int) -> int:
        
        return int(random.gauss(mean, sigma))
558474
function closest(obj, number){		
		if((current = obj.length) < 2)
			return l - 1;
			
		for(var current, previous = Math.abs(obj[--current] - number); current--;)
			if(previous < (previous = Math.abs(obj[current] - number)))
				break;
				
		return obj[current + 1];
	
		var closest = -1,
			prev = Math.abs(obj[0] - number);
		
		for (var i = 1; i < obj.length; i++){
			var diff = Math.abs(obj[i] - number);
			
			if (diff <= prev){
				prev = diff;
				closest = obj[i];
			}
		}
		
		return closest;
	}
1121291
function harmonic_mean(x) {
        // The mean of no numbers is null
        if (x.length === 0) return null;

        var reciprocal_sum = 0;

        for (var i = 0; i < x.length; i++) {
            // the harmonic mean is only valid for positive numbers
            if (x[i] <= 0) return null;

            reciprocal_sum += 1 / x[i];
        }

        // divide n by the the reciprocal sum
        return x.length / reciprocal_sum;
    }
932664
def median(self):
        
        return round(float(np.median(self.array)), self.precision)\
            if len(self.array) else None
1311489
def geomean(array):
    
    n = len(array)

    if n < 1:
        return 0
    elif n == 1:
        return array[0]
    return stats.mstats.gmean(array)
57195
def closest_to_ref(arrays, ref, cutoff=1E-12):
    
    dist = numpy.zeros(len(arrays))
    logref = log(ref, cutoff)
    for rlz, array in enumerate(arrays):
        diff = log(array, cutoff) - logref
        dist[rlz] = numpy.sqrt((diff * diff).sum())
    rlz = dist.argmin()
    closest = dict(rlz=rlz, value=arrays[rlz], dist=dist[rlz])
    return closest
1337793
function arrayMin(data) {
	var i = data.length,
		min = data[0];

	while (i--) {
		if (data[i] < min) {
			min = data[i];
		}
	}
	return min;
}
1085484
function sum_nth_power_deviations(x, n) {
        var mean_value = mean(x),
            sum = 0;

        for (var i = 0; i < x.length; i++) {
            sum += Math.pow(x[i] - mean_value, n);
        }

        return sum;
    }
995531
function arraySampleSize(array, n) {
      return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
    }
557465
public static int searchMin(int[] intArray) {
        if(intArray.length == 0) {
            throw new IllegalArgumentException("The array you provided does not have any elements");
        }

        int min = intArray[0];

        for(int i = 1; i < intArray.length; i++) {
            if(intArray[i] < min) {
                min = intArray[i];
            }
        }

        return min;
    }
1355869
function quantile_sorted(sample, p) {
        var idx = (sample.length) * p;
        if (p < 0 || p > 1) {
            return null;
        } else if (p === 1) {
            // If p is 1, directly return the last element
            return sample[sample.length - 1];
        } else if (p === 0) {
            // If p is 0, directly return the first element
            return sample[0];
        } else if (idx % 1 !== 0) {
            // If p is not integer, return the next element in array
            return sample[Math.ceil(idx) - 1];
        } else if (sample.length % 2 === 0) {
            // If the list has even-length, we'll take the average of this number
            // and the next value, if there is one
            return (sample[idx - 1] + sample[idx]) / 2;
        } else {
            // Finally, in the simple case of an integer value
            // with an odd-length list, return the sample value at the index.
            return sample[idx];
        }
    }
1244702
def index_nearest(value, array):
    

    a = (array-value)**2
    return index(a.min(), a)