Java List std stdev(List values)

Here you can find the source of stdev(List values)

Description

stdev

License

Open Source License

Declaration

public static double stdev(List<Double> values) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2014 Gabriel Skantze./*from w w  w  .  j ava 2  s. c  o  m*/
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl.html
 * 
 * Contributors:
 *     Gabriel Skantze - initial API and implementation
 ******************************************************************************/

import java.util.List;

public class Main {
    public static double stdev(List<? extends Number> data, double mean) {
        float variance = 0;
        for (Number pd : data) {
            variance += Math.pow((pd.doubleValue() - mean), 2)
                    / data.size();
        }
        return Math.sqrt(variance);
    }

    public static double stdev(List<Double> values) {
        return stdev(values, mean(values));
    }

    public static double mean(List<? extends Number> data) {
        double mean = 0;
        for (Number pd : data) {
            mean += pd.doubleValue() / data.size();
        }
        return mean;
    }
}

Related

  1. std(List iNumbers)
  2. std(List vector, Double avg)
  3. stdDev(List nums)
  4. stddev(List observations)
  5. stDev(final List list)
  6. stdInt(List elements)
  7. varianceDouble(List list, boolean populationStandardDeviation)