note 97369 added to function.stats-standard-deviation
| From: | Sharon at osu1 dot php dot net | Date: | Fri, 16 Apr 2010 09:40:46 +0000 |
| Subject: | note 97369 added to function.stats-standard-deviation | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-168311@lists.php.net to get a copy of this message | ||
If you don't have the stat package you can use these functions:
<?php
// Function to calculate square of value - mean
function sd_square($x, $mean) { return pow($x - $mean,2); }
// Function to calculate standard deviation (uses sd_square)
function sd($array) {
// square root of sum of squares devided by N-1
return sqrt(array_sum(array_map("sd_square", $array, array_fill(0,count($array),
(array_sum($array) / count($array)) ) ) ) / (count($array)-1) );
}
?>
----
Server IP: 83.137.20.135
Probable Submitter: 145.18.152.143
----
Manual Page -- http://www.php.net/manual/en/function.stats-standard-deviation.php
Edit -- https://master.php.net/note/edit/97369
Del: integrated -- https://master.php.net/note/delete/97369/integrated
Del: useless -- https://master.php.net/note/delete/97369/useless
Del: bad code -- https://master.php.net/note/delete/97369/bad+code
Del: spam -- https://master.php.net/note/delete/97369/spam
Del: non-english -- https://master.php.net/note/delete/97369/non-english
Del: in docs -- https://master.php.net/note/delete/97369/in+docs
Del: other reasons-- https://master.php.net/note/delete/97369
Reject -- https://master.php.net/note/reject/97369
Search -- https://master.php.net/manage/user-notes.php