calculate Standard Deviation - Java java.lang

Java examples for java.lang:Math Operation

Description

calculate Standard Deviation

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        double variance = 2.45678;
        long counter = 2;
        System.out.println(calcStdDev(variance, counter));
    }/*www. j a va2 s .c  o  m*/

    public static double calcStdDev(double variance, long counter) {

        double stdDev = Double.NaN;
        if (counter > 0) {
            if (counter > 1) {
                stdDev = Math.sqrt(variance);
            } else {
                stdDev = 0.0;
            }
        }
        return stdDev;

    }
}

Related Tutorials