smerny Posted November 22, 2009 Share Posted November 22, 2009 http://us3.php.net/manual/en/function.stats-standard-deviation.php Warning This function is currently not documented; only its argument list is available. this doesn't work for me, "undefined function", is there something I can do? or another function to use? or do I just need to create my own to use? Quote Link to comment https://forums.phpfreaks.com/topic/182518-statistics_stardard_deviation/ Share on other sites More sharing options...
Alex Posted November 22, 2009 Share Posted November 22, 2009 Well after 10 minutes of trying to figure out how to use 'bar x' in the [tex] tag.. You can install the math extension, or just create your own standard_deviation function, it's not that hard.. Ex: <?php function standard_deviation($arr) { $bar_x = array_sum($arr) / count($arr); foreach($arr as $x) $dev[] = pow($x - $bar_x, 2); return sqrt(array_sum($dev) / count($arr)); } echo standard_deviation(Array(78, 84, 86, 92, 95)); // 6 Quote Link to comment https://forums.phpfreaks.com/topic/182518-statistics_stardard_deviation/#findComment-963360 Share on other sites More sharing options...
smerny Posted November 22, 2009 Author Share Posted November 22, 2009 okay, thanks Quote Link to comment https://forums.phpfreaks.com/topic/182518-statistics_stardard_deviation/#findComment-963366 Share on other sites More sharing options...
Alex Posted November 22, 2009 Share Posted November 22, 2009 Figured it out, this is what I was trying to post originally.. [tex]\sigma = \sqrt{\frac{\sum_{n = 1}^n (x - \overline{x})^2}{n}}[/tex] Quote Link to comment https://forums.phpfreaks.com/topic/182518-statistics_stardard_deviation/#findComment-963368 Share on other sites More sharing options...
smerny Posted November 22, 2009 Author Share Posted November 22, 2009 that's for population standard deviation btw, the denominator is n-1 for sample standard deviation Quote Link to comment https://forums.phpfreaks.com/topic/182518-statistics_stardard_deviation/#findComment-963370 Share on other sites More sharing options...
Alex Posted November 22, 2009 Share Posted November 22, 2009 You didn't say you were trying to find sample standard deviation. Quote Link to comment https://forums.phpfreaks.com/topic/182518-statistics_stardard_deviation/#findComment-963371 Share on other sites More sharing options...
Mchl Posted November 22, 2009 Share Posted November 22, 2009 If you have this data in MySQL, you can use one of these http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html#function_var-pop Quote Link to comment https://forums.phpfreaks.com/topic/182518-statistics_stardard_deviation/#findComment-963372 Share on other sites More sharing options...
smerny Posted November 22, 2009 Author Share Posted November 22, 2009 You didn't say you were trying to find sample standard deviation. xbar is also for a sample Quote Link to comment https://forums.phpfreaks.com/topic/182518-statistics_stardard_deviation/#findComment-963381 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.