Here you can find the source of stdDeviation(int[] data)
Parameter | Description |
---|---|
x | a parameter |
public static double stdDeviation(int[] data)
//package com.java2s; //License from project: Open Source License public class Main { /**//from w ww .ja va 2s . co m * Returns standard deviation of array of ints * * @param x * @return */ public static double stdDeviation(int[] data) { double mean = mean(data); double sum = 0; for (int i = 0; i < data.length; i++) { sum += Math.pow(data[i] - mean, 2); } return Math.sqrt((sum) / (data.length - 1)); } /** * Returns mean of array of ints * * @param data * @return */ public static double mean(int[] data) { int sum = 0; for (int i = 0; i < data.length; i++) { sum += data[i]; } return (sum / data.length); } }