Bluehost.com Web Hosting $6.95

stats_standard_deviation

This is a discussion on stats_standard_deviation within the PHP Language forums, part of the PHP Programming Forums category; Does anyone have more details on stats_standard_deviation than the manual provides? -- Regards, Jeff Gardner ___________________________ "Contrary to popular belief, ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-04-2006
Jeff Gardner
 
Posts: n/a
Default stats_standard_deviation

Does anyone have more details on stats_standard_deviation than the
manual provides?
--

Regards,

Jeff Gardner
___________________________

"Contrary to popular belief, Unix is user friendly. It just happens
to be very selective about who its friends are." --Kyle Hearn
Reply With Quote
  #2 (permalink)  
Old 10-05-2006
Erwin Moller
 
Posts: n/a
Default Re: stats_standard_deviation

Jeff Gardner wrote:

> Does anyone have more details on stats_standard_deviation than the
> manual provides?


Hi Jeff,

The describtion is very bad indeed.

Why use an undocumented (bad documented) function for such a simple thing?
I would write my own implementation in such case.
Calculation the SD is very straightforward.

On the same page on www.php.net you can also find a contribution with a
working example.

[Source]
http://nl2.php.net/manual/en/functio...-deviation.php

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;
}

Regards,
Erwin Moller



Reply With Quote
  #3 (permalink)  
Old 10-05-2006
NC
 
Posts: n/a
Default Re: stats_standard_deviation

Jeff Gardner wrote:
>
> Does anyone have more details on stats_standard_deviation
> than the manual provides?


Why bother? Standard deviation is a really simple thing to
compute:

function stat_mean ($data) {
return (array_sum($data) / count($data));
}

function stat_var ($data) {
$n = count ($data);
$mean = stat_mean ($data);
$sum = 0;
foreach ($data as $element) {
$sum += pow (($element - $mean), 2);
}
return ($sum / ($n - 1));
}

function stat_stdev ($data) {
return sqrt (stat_var($data));
}

Cheers,
NC

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 12:22 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0