PhpBench\Math\Distribution::getMean PHP Method

getMean() public method

public getMean ( )
    public function getMean()
    {
        return $this->getStat('mean');
    }

Usage Example

Example #1
0
 /**
  * Calculate and set the deviation from the mean time for each iteration. If
  * the deviation is greater than the rejection threshold, then mark the iteration as
  * rejected.
  */
 public function computeStats()
 {
     $this->rejects = [];
     $revs = $this->getRevolutions();
     if (0 === count($this->iterations)) {
         return;
     }
     $times = $this->getMetricValuesByRev(TimeResult::class, 'net');
     $retryThreshold = $this->getSubject()->getRetryThreshold();
     $this->stats = new Distribution($times, $this->computedStats);
     foreach ($this->iterations as $iteration) {
         // deviation is the percentage different of the value from the mean of the set.
         if ($this->stats->getMean() > 0) {
             $deviation = 100 / $this->stats->getMean() * ($iteration->getResult(TimeResult::class)->getRevTime($iteration->getVariant()->getRevolutions()) - $this->stats->getMean());
         } else {
             $deviation = 0;
         }
         // the Z-Value represents the number of standard deviations this
         // value is away from the mean.
         $revTime = $iteration->getResult(TimeResult::class)->getRevTime($revs);
         $zValue = $this->stats->getStdev() ? ($revTime - $this->stats->getMean()) / $this->stats->getStdev() : 0;
         if (null !== $retryThreshold) {
             if (abs($deviation) >= $retryThreshold) {
                 $this->rejects[] = $iteration;
             }
         }
         $iteration->setResult(new ComputedResult($zValue, $deviation));
     }
     $this->computed = true;
 }
All Usage Examples Of PhpBench\Math\Distribution::getMean