Java List std std(List vector, Double avg)

Here you can find the source of std(List vector, Double avg)

Description

std

License

Open Source License

Declaration

public static Double std(List<Double> vector, Double avg) 

Method Source Code

//package com.java2s;
/**//  ww  w  .ja v a 2  s  .c  o  m
 * Part of program for analyze speech signal 
 * Copyright (c) 2008 Mindaugas Greibus (spantus@gmail.com)
 * http://code.google.com/p/spantus/
 * 
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2 of the License, or (at your
 * option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 675 Mass Ave, Cambridge, MA 02139, USA.
 * 
 */

import java.util.List;

public class Main {
    public static Double std(List<Double> vector, Double avg) {
        Double accum = 0.0;
        Double dev = 0.0;
        Double accum2 = 0.0;
        Double len = (double) vector.size();

        for (Double float1 : vector) {
            dev = float1 - avg;
            accum += dev * dev;
            accum2 += dev;
        }
        Double var = (accum - (accum2 * accum2 / len)) / len;
        return Math.sqrt(var);
    }
}

Related

  1. standardDeviation(List values)
  2. standardDeviation(List list)
  3. standardDeviation(List values, double xbar)
  4. standardDeviationDouble(List list, boolean populationStandardDeviation)
  5. std(List iNumbers)
  6. stdDev(List nums)
  7. stddev(List observations)
  8. stDev(final List list)
  9. stdev(List values)