Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
0
 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);
 }
Exemplo n.º 3
0
 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);
 }
Exemplo n.º 4
0
 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;
 }
Exemplo n.º 5
0
 public static double geometricPdf(int k, double p) {
   return p * Math.pow(1 - p, k);
 }