Stream::Aggregate::Stats - some standard statistics functions
use Stream::Aggregate::Stats; $data = [ 1, 2, 3, 5, 9 ]; $mydata = { keep => { fieldname => $data, }, numeric => { }, }; local($Stream::Aggregate::Stats::ps) = $mydata; $mean = mean('fieldname');
This module implements some standard statistics functions. It has an odd API: it expect the data to be inside a structure. This is to facilitate uses where the operations are found at runtime from user input or configuration files.
The exact structure is:
{ keep => { field1 => [ @data ], field2 => [ @data ], field3 => [ @data ], }, numeric => {}, }
where field1, field2, etc are names for the data. You then ask for functions by name: eg: mean('field1').
field1
field2
mean('field1')
The functions available are: percentile, standard_deviation, median, mean, largest (numeric max), smallest (numeric min), dominant (the mode), and dominantcount. The percentile function takes two arguments: the field name and the percentile: percentile(field1 => 80) gives you the 80th percentle for the data in field1. The 50th percentile is the same as the median. The dominantcount is the number of values that exactly matched the mode.
percentile
standard_deviation
median
mean
largest
smallest
dominant
dominantcount
percentile(field1 => 80)
This package may be used and redistributed under the terms of either the Artistic 2.0 or LGPL 2.1 license.
To install Stream::Aggregate, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Stream::Aggregate
CPAN shell
perl -MCPAN -e shell install Stream::Aggregate
For more information on module installation, please visit the detailed CPAN module installation guide.