David Muir Sharnoff > Stream-Aggregate-0.406 > Stream::Aggregate::Stats

Download:
modules/Stream-Aggregate-0.406.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Source  

NAME ^

Stream::Aggregate::Stats - some standard statistics functions

SYNOPSIS ^

 use Stream::Aggregate::Stats;

 $data = [ 1, 2, 3, 5, 9 ];
 $mydata = {
        keep => {
                fieldname       => $data,
        },
        numeric => { },
 };

 local($Stream::Aggregate::Stats::ps) = $mydata;
 
 $mean = mean('fieldname');

DESCRIPTION ^

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').

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.

LICENSE ^

This package may be used and redistributed under the terms of either the Artistic 2.0 or LGPL 2.1 license.

syntax highlighting: