Generating descriptive statistics
Descriptive statistics are used to summarize a sample and are not generally developed based on probability theories. In contrast, inferential statistics are mostly used to draw a conclusion about the population from a representative sample of it. In this recipe, we will see how we can use Java to generate descriptive statistics from small samples.
Without broadening the scope of this recipe too much, we will be focusing only on a subset of descriptive statistics listed here.
How to do it...
Create a method that takes a
double
array as argument. The array will contain the values for which you are going to compute the descriptive statistics:public void getDescStats(double[] values){
Create an object of theÂ
DescriptiveStatistics
type:DescriptiveStatistics stats = new DescriptiveStatistics();
Loop through all the values of the double array, and add them to the
DescriptiveStatistic
 object:for( int i = 0; i < values.length;...