public static double sumOfPowerOfDeviations(double[] data, int k, double c) { double sum = 0; for (int i = 0; i < data.length; i++) { sum += Math.pow(data[i] - c, k); } return sum; }
public static double skew(double[] data) { double sum = 0; double sumPD = 0; double sumSq = 0; for (int i = 0; i < data.length; i++) { sum += data[i]; sumSq += data[i] * data[i]; } double mean = sum / data.length; double standardDeviation = Math.sqrt((sumSq - mean * sum) / data.length); for (int i = 0; i < data.length; i++) { sumPD += Math.pow(data[i] - mean, 3); } double moment3 = sumPD / data.length; return moment3 / (standardDeviation * standardDeviation * standardDeviation); }
public static double kurtosis(double[] data) { double sum = 0; double sumPD = 0; double sumSq = 0; for (int i = 0; i < data.length; i++) { sum += data[i]; sumSq += data[i] * data[i]; } double mean = sum / data.length; double standardDeviation = Math.sqrt((--sumSq - mean * sum) / data.length); for (int i = 0; i < data.length; i++) { sumPD += Math.pow(data[i] - mean, 4); } double moment4 = sumPD / data.length; return -3 + moment4 / (standardDeviation * standardDeviation * standardDeviation * standardDeviation); }
public static double[] power(double[] data, int k) { for (int i = 0; i < data.length; i++) { data[i] = Math.pow(data[i], k); } return data; }
public static double geometricPdf(int k, double p) { return p * Math.pow(1 - p, k); }