OneVariableStats implements Serializable { public double std() { if (min == max || num == 0) { return 0; } double m = mean(); return Math.sqrt(sigmax2 / num - m * m); } OneVariableStats(); void reset(); void add(double d); double mean(); double std(); double stdErr(); double min(); double max();  }
@Test public void testStd() throws Exception { OneVariableStats oneVariableStats = new OneVariableStats(); assertEquals(0.0, oneVariableStats.std(), 0.0); oneVariableStats.add(1.0); oneVariableStats.add(2.0); oneVariableStats.add(3.0); oneVariableStats.add(4.0); oneVariableStats.add(5.0); assertEquals(1.4142, oneVariableStats.std(), 0.001); }