Java tutorial
//package com.java2s; public class Main { public static double deviation(double[] data) { if (data.length < 2) { return 0; } double avg = average(data); double sum = 0; for (double element : data) { sum += (element - avg) * (element - avg); } return Math.sqrt(sum / (data.length - 1)); } public static double average(double[] data) { double avg = 0; for (double element : data) { avg += element / data.length; } return avg; } }