Java Variance variances(double[] data)

Here you can find the source of variances(double[] data)

Description

variances

License

Open Source License

Declaration

private static double[] variances(double[] data) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    private static double[] variances(double[] data) {
        double sum = 0;
        double sumsquare = 0;
        int len = data.length;
        double mean = 0;
        double[] variances = new double[len];
        for (int i = 0; i < len; ++i) {
            sum += data[i];/*from  w w w . j av  a 2  s  .  c  o  m*/
            sumsquare += data[i] * data[i];
            mean = sum / (i + 1);
            variances[i] = sumsquare / (i + 1) - mean * mean;
        }
        return variances;
    }
}

Related

  1. variance(final double[] values)
  2. variance(final double[] values, final double mean)
  3. variance(final int[] scores)
  4. variance(float[] v, float average)
  5. variance(Integer[] values)
  6. varianceTwo(final double[] values)