ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
Math_Stats Namespace Reference

A class to calculate descriptive statistics from a data set. More...

Detailed Description

A class to calculate descriptive statistics from a data set.

Data sets can be simple arrays of data, or a cummulative hash. The second form is useful when passing large data set, for example the data set:

$data1 = array (1,2,1,1,1,1,3,3,4.1,3,2,2,4.1,1,1,2,3,3,2,2,1,1,2,2);

can be epxressed more compactly as:

$data2 = array('1'=>9, '2'=>8, '3'=>5, '4.1'=>2);

Example of use:

include_once 'Math/Stats.php';
$s = new Math_Stats();
$s->setData($data1);
// or
// $s->setData($data2, STATS_DATA_CUMMULATIVE);
$stats = $s->calcBasic();
echo 'Mean: '.$stats['mean'].' StDev: '.$stats['stdev'].' 

';
// using data with nulls
// first ignoring them:
$data3 = array(1.2, 'foo', 2.4, 3.1, 4.2, 3.2, null, 5.1, 6.2);
$s->setNullOption(STATS_IGNORE_NULL);
$s->setData($data3);
$stats3 = $s->calcFull();
// and then assuming nulls == 0
$s->setNullOption(STATS_USE_NULL_AS_ZERO);
$s->setData($data3);
$stats3 = $s->calcFull();

Originally this class was part of NumPHP (Numeric PHP package)

Author
Jesus M. Castagnetto jmcas.nosp@m.tagn.nosp@m.etto@.nosp@m.php..nosp@m.net
Version
0.8 public