note 66447 added to function.stats-standard-deviation

From: Date: Tue, 23 May 2006 00:52:24 +0000
Subject: note 66447 added to function.stats-standard-deviation
Groups: php.notes 
Request: Send a blank email to php-notes+get-111842@lists.php.net to get a copy of this message
Here's a couple functions I made that easily calculate the standard deviation. function average($array){ $sum = array_sum($array); $count = count($array); return $sum/$count; } //The average function can be use independantly but the deviation function uses the average function. function deviation ($array){ $avg = average($array); foreach ($array as $value) { $variance[] = pow($value-$avg, 2); } $deviation = sqrt(average($variance)); return $deviation; } I hope this is useful ---- Server IP: 64.71.164.2 Probable Submitter: 207.138.31.81 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.stats-standard-deviation.php Edit -- http://master.php.net/note/edit/66447 Del: integrated -- http://master.php.net/note/delete/66447/integrated Del: useless -- http://master.php.net/note/delete/66447/useless Del: bad code -- http://master.php.net/note/delete/66447/bad+code Del: spam -- http://master.php.net/note/delete/66447/spam Del: non-english -- http://master.php.net/note/delete/66447/non-english Del: in docs -- http://master.php.net/note/delete/66447/in+docs Del: other reasons-- http://master.php.net/note/delete/66447 Reject -- http://master.php.net/note/reject/66447 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#111842) next »