Here you can find the source of std(final double[] x, final int begin, final int end)
public static double std(final double[] x, final int begin, final int end)
//package com.java2s; /**/* w w w . j a va2s.c o m*/ * Copyright? 2014-2016 LIST (Luxembourg Institute of Science and Technology), all right reserved. * Authorship : Olivier PARISOT, Yoanne DIDRY * Licensed under GNU General Public License version 3 */ public class Main { public static double std(final double[] x, final int begin, final int end) { int N = 0; double mean = 0d; for (int i = Math.max(0, begin); i < Math.min(x.length - 1, end); i++) { mean += x[i]; N++; } mean /= N; double std = 0d; for (int i = Math.max(0, begin); i < Math.min(x.length - 1, end); i++) { std += (x[i] - mean) * (x[i] - mean); } return Math.sqrt(std / N); } public static double std(final double[] x) { final int N = x.length; final double avg = avg(x); double std = 0; for (int i = 0; i < N; i++) { std += (x[i] - avg) * (x[i] - avg); } return Math.sqrt(std / N); } public static double avg(final double... values) { return sum(values) / values.length; } public static double sum(final double... values) { double result = 0d; for (final double value : values) result += value; return result; } public static long sum(final long... values) { long result = 0; for (final long value : values) result += value; return result; } }