/** * This method calculates the skewness of a data set. Skewness is the third central moment divided by the third * power of the standard deviation. * * @param data * The input data set * * @return the skewness of <tt>data</tt>. */ public static double skewness(double[] data) { if (data == null || data.length < 2) { return Double.NaN; } else { double m3 = moment(data, 3); double sm2 = Math.sqrt(moment(data, 2)); return m3 / Math.pow(sm2, 3); } }
/** * This method calculates the kurtosis of a data set. Kurtosis is the fourth central moment divided by the fourth * power of the standard deviation. * * @param data * The input data set * * @return the kurtosis of <tt>data</tt>. */ public static double kurtosis(double[] data) { if (data == null || data.length < 2) { return Double.NaN; } else { double m4 = moment(data, 4); double sm2 = Math.sqrt(moment(data, 2)); return m4 / Math.pow(sm2, 4); } }