note 31295 added to ref.math
| From: | jerry dot wilborn at fast dot net | Date: | Wed, 16 Apr 2003 16:10:41 +0000 |
| Subject: | note 31295 added to ref.math | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-46696@lists.php.net to get a copy of this message | ||
Here is how to calculate standard deviation in PHP where $samples is an array of incrementing
numeric keys and the values are your samples:
$sample_count = count($samples);
for ($current_sample = 0; $sample_count > $current_sample; ++$current_sample)
$sample_square[$current_sample] = pow($samples[$current_sample], 2);
$standard_deviation = sqrt(array_sum($sample_square) / $sample_count - pow((array_sum($samples) /
$sample_count), 2));
--
http://www.php.net/manual/en/ref.math.php
http://master.php.net/manage/user-notes.php?action=edit+31295
http://master.php.net/manage/user-notes.php?action=delete+31295
http://master.php.net/manage/user-notes.php?action=reject+31295