* $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); *
* $data2 = array("1"=>9, "2"=>8, "3"=>5, "4.1"=>2); *
* 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"]." \n"; * * // 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(); *