Statistical tools in APACHE common

Source: Internet
Author: User

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 ));

}

}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.