[ create a new paste ] login | about

Link: http://codepad.org/btWcjHZy    [ raw code | output | fork ]

PHP, pasted on Jun 7:
<?php
$start = 0;
$top = 10000;
$ar = array();
for ($x=1;$x<=10000;$x++) {
  $val = mt_rand($start, $top) / $top;
  $ar[] = $val;
}

$mean = array_sum($ar) / sizeof($ar);

$devs = array();
foreach($ar as $num) {
    $devs[] = pow($num - $mean, 2);
}

$standard_deviation = sqrt(array_sum($devs) / sizeof($devs));



echo 'Max: ' . max($ar);
echo chr(10);
echo 'Min: ' . min($ar);
echo chr(10);
echo 'Average: ' . $mean;
echo chr(10);
echo 'Deviation: ' . $standard_deviation;
?>


Output:
1
2
3
4
Max: 1
Min: 0
Average: 0.49865689
Deviation: 0.29010396801927


Create a new paste based on this one


Comments: