Calculate standart deviation.
@param values Values.
@param mean Mean.
@return Standart deviation.
193160
public static double StdDev( int[] values, double mean ){
        double  stddev = 0;
        double  diff;
        int     hits;
        int     total = 0;

        // for all values
        for ( int i = 0, n = values.length; i < n; i++ )
        {
            hits = values[i];
            diff = (double) i - mean;
            // accumulate std.dev.
            stddev += diff * diff * hits;
            // accumalate total
            total += hits;
        }

        return ( total == 0 ) ? 0 : Math.sqrt( stddev / (total - 1) );
    }
622158
public static Statistics statisticsFor( long[] values ) {
        int length = values.length;
        if (length == 0) return EMPTY_STATISTICS;
        if (length == 1) return statisticsFor(values[0]);
        long total = 0L;
        long max = Long.MIN_VALUE;
        long min = Long.MAX_VALUE;
        for (long value : values) {
            total += value;
            max = Math.max(max, value);
            min = Math.min(min, value);
        }
        double mean = ((double)total) / length;
        double varianceSquared = 0.0d;
        double distance = 0.0d;
        for (long value : values) {
            distance = mean - value;
            varianceSquared = varianceSquared + (distance * distance);
        }
        return new StatisticsImpl(length, min, max, mean, Math.sqrt(varianceSquared));
    }
166370
public static double Kurtosis(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);
        part1 /= ((n - 1) * (n - 2) * (n - 3));
        
        double part2 = 0;
        for (int i = 0; i < values.length; i++) {
            part2 += Math.pow((i - mean) / stdDeviation, 4) * values[i];
        }
        
        double part3 = 3 * Math.pow((n - 1), 2);
        part3 /= (n - 2) * (n - 3);
        
        return part1 * part2 - part3;
    }
119990
public List<Double> std(List<Double> mean) {
    List<Double> result = new ArrayList<>(mean.size());
    result.addAll(this.variance(mean));
    for (int i = 0; i < result.size(); i++)
      result.set(i,Math.sqrt(result.get(i)));

    return result;
  }

  public void mark(int index) {
    this.marks.set(index, MAX_LENGHT);
  }

  public boolean isUnMarked(int index) {
    return this.marks.get(index) == 0;
  }

  public void decreaseMark(int index) {
    if (this.marks.get(index) > 0)
      this.marks.set(index,this.marks.get(index)-1);
  }

  public Double getMaxObjective(int index) {
    Double result = Double.NEGATIVE_INFINITY;

    for (List<Double> list : this.history)
      result = Math.max(result, list.get(index));

    return result;
  }
}
1362236
public static double min(final double[] values) {
		double min = NaN;
		if (values.length > 0) {
			min = values[0];

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

		return min;
	}
902241
public MeanVariance averageSymmetricGini() {
    MeanVariance mv = new MeanVariance();
    for(int i1 = 0; i1 < size1; i1++) {
      double purity = 0.0;
      if(contingency[i1][size2] > 0) {
        final double cs = contingency[i1][size2]; // sum, as double.
        for(int i2 = 0; i2 < size2; i2++) {
          double rel = contingency[i1][i2] / cs;
          purity += rel * rel;
        }
        mv.put(purity, cs);
      }
    }
    for(int i2 = 0; i2 < size2; i2++) {
      double purity = 0.0;
      if(contingency[size1][i2] > 0) {
        final double cs = contingency[size1][i2]; // sum, as double.
        for(int i1 = 0; i1 < size1; i1++) {
          double rel = contingency[i1][i2] / cs;
          purity += rel * rel;
        }
        mv.put(purity, cs);
      }
    }
    return mv;
  }
368161
private Double aggregate(Datasource ds, Collection<Double> values) {
        return ((values.size() / m_intervalsPer) > ds.getXff()) ? ds.getAggregationFuction().apply(values) : Double.NaN;
    }
1131218
public static function centralMoment(array $values, int $moment, ?float $mean = null, ?int $n = null) : float
    {
        $n = $n ?? count($values);

        if ($n < 1) {
            throw new InvalidArgumentException('Central moment is undefined for'
                . ' empty set.');
        }

        $mean = $mean ?? self::mean($values, $n);

        $sigma = 0.;

        foreach ($values as $value) {
            $sigma += ($value - $mean) ** $moment;
        }

        return $sigma / $n;
    }
945798
public static double variance( GrayS8 img , double mean ) {

		if( BoofConcurrency.USE_CONCURRENT ) {
			return ImplImageStatistics_MT.variance(img,mean);
		} else {
			return ImplImageStatistics.variance(img,mean);
		}
	}
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))
76187
public void setMean(double mean)
    {
        if(Double.isInfinite(mean) || Double.isNaN(mean))
            throw new ArithmeticException("Mean must be a real number, not " + mean);
        ((Normal)getDistribution()).setMean(mean);
    }
76466
public static double standardDeviation(double[] x, double mean) {
        if (x.length == 0) {
            return Double.NaN;
        }
        if (x.length == 1) {
            return 0.0;
        }
        return Math.sqrt(variance(x, mean));
    }
110156
@SuppressWarnings("unchecked")
    public static int median(List<Integer> values) {
        if (values == null || values.isEmpty()) return 0;

        values = new ArrayList<Integer>(values);
        Collections.sort(values);

        final int size = values.size();
        final int sizeHalf = size / 2;
        if (size % 2 == 1) { //is odd?
            // 0 1 [2] 3 4: size/2 = 5/2 = 2.5 -> 2
            return values.get(sizeHalf);
        }

        // 0 1 [2 3] 4 5: size/2 = 6/2 = 3
        return (values.get(sizeHalf - 1) + values.get(sizeHalf)) / 2;
    }
1130517
def deviation(self, series, start, limit, mean):
        '''
        
        '''
        d = []
        for x in range(start, limit):
            d.append(float(series[x] - mean))
        return d
699347
public static function mean(array $values, ?int $n = null) : float
    {
        $n = $n ?? count($values);

        if ($n < 1) {
            throw new InvalidArgumentException('Mean is undefined for empty'
                . ' set.');
        }

        return array_sum($values) / $n;
    }
73869
public static double[] Normalize(int[] values){
        int sum = 0;
        for (int i = 0; i < values.length; i++) {
            sum += values[i];
        }
        
        double[] norm = new double[values.length];
        for (int i = 0; i < norm.length; i++) {
            norm[i] = values[i] / (double)sum;
        }
        
        return norm;
    }
1238078
public static float Variance(ImageSource fastBitmap, float mean) {
        return Variance(fastBitmap, mean, 0, 0, fastBitmap.getWidth(), fastBitmap.getHeight());
    }