Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Descriptive Statistics from Java ArrayList

I have ArrayList of Profile object. Profile have properties like age, gender, country, etc.

Are there any library in java which can give descriptive statistics easily like number of female profile, number of male profile, number of female profile from USA, and other complex report.

The environment used is Google App Engine.

Thanks

like image 504
JR Galia Avatar asked Oct 06 '22 09:10

JR Galia


1 Answers

You can use descriptive statistics in apache commons math e.g.

// Get a DescriptiveStatistics instance
DescriptiveStatistics stats = new DescriptiveStatistics();

// Add the data from the array
for( int i = 0; i < inputArray.length; i++) {
        stats.addValue(inputArray[i]);
}

// Compute some statistics
double mean = stats.getMean();
double std = stats.getStandardDeviation();

You will need to add the gender/country information into the descriptiveStatistics provided by commons math. Hope it helps.

like image 153
ali haider Avatar answered Oct 10 '22 03:10

ali haider