1 16 package org.apache.commons.math.stat.descriptive.moment; 17 18 import java.io.Serializable ; 19 20 44 public class SecondMoment extends FirstMoment implements Serializable { 45 46 47 static final long serialVersionUID = 3942403127395076445L; 48 49 50 protected double m2; 51 52 55 public SecondMoment() { 56 super(); 57 m2 = Double.NaN; 58 } 59 60 63 public void increment(final double d) { 64 if (n < 1) { 65 m1 = m2 = 0.0; 66 } 67 super.increment(d); 68 m2 += ((double) n - 1) * dev * nDev; 69 } 70 71 74 public void clear() { 75 super.clear(); 76 m2 = Double.NaN; 77 } 78 79 82 public double getResult() { 83 return m2; 84 } 85 86 } 87 | Popular Tags |