Standar Deviation PHP function


SUBMITTED BY: Guest

DATE: Dec. 5, 2013, 3:29 a.m.

FORMAT: PHP

SIZE: 256 Bytes

HITS: 779

  1. function standard_deviation($sample){
  2. if(is_array($sample)){
  3. $mean = array_sum($sample) / count($sample);
  4. foreach($sample as $key => $num) $devs[$key] = pow($num - $mean, 2);
  5. return sqrt(array_sum($devs) / (count($devs) - 1));
  6. }
  7. }

comments powered by Disqus