You are here

function pData::getStandardDeviation in Visitors 7.2

Same name and namespace in other branches
  1. 7 pChart/class/pData.class.php \pData::getStandardDeviation()
1 call to pData::getStandardDeviation()
pData::getCoefficientOfVariation in pChart/class/pData.class.php

File

pChart/class/pData.class.php, line 309

Class

pData

Code

function getStandardDeviation($Serie) {
  if (isset($this->Data["Series"][$Serie])) {
    $Average = $this
      ->getSerieAverage($Serie);
    $SerieData = $this
      ->stripVOID($this->Data["Series"][$Serie]["Data"]);
    $DeviationSum = 0;
    foreach ($SerieData as $Key => $Value) {
      $DeviationSum = $DeviationSum + ($Value - $Average) * ($Value - $Average);
    }
    $Deviation = sqrt($DeviationSum / count($SerieData));
    return $Deviation;
  }
  else {
    return NULL;
  }
}