PhpBench\Math\Statistics::mean PHP Method

mean() public static method

Return the mean (average) value of the given values.
public static mean ( array $values ) : mixed
$values array
return mixed
    public static function mean($values)
    {
        if (empty($values)) {
            return 0;
        }
        $sum = array_sum($values);
        if (0 == $sum) {
            return 0;
        }
        $count = count($values);
        return $sum / $count;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Return the average relative standard deviation of all the iteration sets.
  *
  * @return float
  */
 public function getMeanRelStDev()
 {
     $rStDevs = array();
     foreach ($this->query('//stats') as $stats) {
         $rStDevs[] = $stats->getAttribute('rstdev');
     }
     return Statistics::mean($rStDevs);
 }
All Usage Examples Of PhpBench\Math\Statistics::mean