Java mean stdevm(double[] values, double mean)

Here you can find the source of stdevm(double[] values, double mean)

Description

stdevm

License

Apache License

Declaration

public static double stdevm(double[] values, double mean) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {

    public static double stdevm(double[] values, double mean) {

        if (values == null || Double.isNaN(mean)) {
            return Double.NaN;
        }/*from  w ww. j  a  v a2 s. c  om*/

        double sum_sq = 0;
        int n = 0;
        for (int k = 0; k < values.length; k++) {
            if (Double.isNaN(values[k])) {
                continue;
            }

            n++;
            sum_sq += (values[k] - mean) * (values[k] - mean);
        }

        if (n == 0) {
            return Double.NaN;
        }

        return Math.sqrt(sum_sq / n);
    }
}

Related

  1. std(double[] a, int size, double mean)
  2. std(double[] array, double mean)
  3. stdDeviation(int[] values, double mean)
  4. stdDevsOfRows(double[][] matrix, double[] means)
  5. stdev(final double[] values, final double mean)