Package com. njs. math;
Import org. apache. commons. math. stat. descriptive. moment. GeometricMean;
Import org. apache. commons. math. stat. descriptive. moment. Kurtosis;
Import org. apache. commons. math. stat. descriptive. moment. Mean;
Import org. apache. commons. math. stat. descriptive. moment. Skewness;
Import org. apache. commons. math. stat. descriptive. moment. StandardDeviation;
Import org. apache. commons. math. stat. descriptive. moment. Variance;
Import org. apache. commons. math. stat. descriptive. rank. Max;
Import org. apache. commons. math. stat. descriptive. rank. Min;
Import org. apache. commons. math. stat. descriptive. rank. Percentile;
Import org. apache. commons. math. stat. descriptive. summary. Product;
Import org. apache. commons. math. stat. descriptive. summary. Sum;
Import org. apache. commons. math. stat. descriptive. summary. SumOfSquares;
Public class mathdemo {
/**
* @ Param ARGs
*/
Public static void main (string [] ARGs ){
Double [] values = new double [] {0.33, 1.33, 0.27333, 0.3, 0.501,
0.444, 0.44, 0.34496, 0.33, 0.3, 0.292, 0.667 };
Min = new min (); // minimum
Max max = new max (); // maximum
Mean mean = new mean (); // arithmetic mean value
Product = new product (); // multiply all numbers
Sum = new sum (); // arithmetic and
Variance variance = new variance (); // variance
System. Out. println ("Min:" + min. Evaluate (values ));
System. Out. println ("MAX:" + Max. Evaluate (values ));
System. Out. println ("mean:" + mean. Evaluate (values ));
System. Out. println ("product:" + product. Evaluate (values ));
System. Out. println ("sum:" + sum. Evaluate (values ));
System. Out. println ("Variance:" + variance. Evaluate (values ));
/**
* The percentile (array, p) algorithm is generally used to sort the array from small to large, and calculate (n-1) * The integer part of P is I, and the fractional part is J, where N is the array size, the percentile value is: (1-j) * Number of array I + 1 + number of J * array I + 2.
* For example, {30%,} calculates the quantile:
* (16-1) * 30% = 4.5, I = 4, j = 0.5
* Percentile (A, 30%) = (1-0.5) * 6 + 0.5*7 = 6.5
**/
Percentile percentile = new percentile (); // percentile
Geometricmean geomean = new geometricmean (); // geometric mean. the n-th arithmetic root of the product of n positive numbers is the geometric mean of N numbers.
Skewness skewness = new skewness (); // skewness;
Kurtosis = new kurtosis (); // kurtosis Kurtosis
Sumofsquares = new sumofsquares (); // sum of squares
Standarddeviation = new standarddeviation (); // standard variance
System. Out. println ("80 percentile value:" + percentile. Evaluate (values, 80.0 ));
System. out. println ("geometric mean:" + geoMean. evaluate (values ));
System. out. println ("skewness:" + skewness. evaluate (values ));
System. out. println ("kurtosis:" + kurtosis. evaluate (values ));
System. out. println ("sumOfSquares:" + sumOfSquares. evaluate (values ));
System. out. println ("StandardDeviation:" + StandardDeviation. evaluate (values ));
}
}