kdeMode() public static method

The mode is the point in the kernel density estimate with the highest frequency, i.e. the time which correlates with the highest peak. If there are two or more modes (i.e. bimodal, trimodal, etc) then we could take the average of these modes. NOTE: If the kde estimate of the population is multi-modal (it has two points with exactly the same value) then the mean mode is returned. This is potentially misleading, but When benchmarking this should be a very rare occurance.
public static kdeMode ( array $population, integer $space = 512, float $bandwidth = null ) : float[]
$population array
$space integer
$bandwidth float
return float[]
Exemplo n.º 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 = array();
     if (0 === count($this->iterations)) {
         return;
     }
     $times = array();
     foreach ($this->iterations as $iteration) {
         $times[] = $iteration->getResult()->getTime() / $iteration->getRevolutions();
     }
     // standard deviation for T Distribution
     $this->stats['stdev'] = Statistics::stdev($times);
     // mean of the times
     $this->stats['mean'] = Statistics::mean($times);
     // mode based on the kernel distribution function
     $this->stats['mode'] = Statistics::kdeMode($times);
     // relative standard error
     $this->stats['rstdev'] = $this->stats['stdev'] / $this->stats['mean'] * 100;
     // variance
     $this->stats['variance'] = Statistics::variance($times);
     // min and max
     $this->stats['min'] = min($times);
     $this->stats['max'] = max($times);
     foreach ($this->iterations as $iteration) {
         // deviation is the percentage different of the value from the mean of the set.
         $deviation = 100 / $this->stats['mean'] * ($iteration->getResult()->getTime() / $iteration->getRevolutions() - $this->stats['mean']);
         $iteration->setDeviation($deviation);
         // the Z-Value represents the number of standard deviations this
         // value is away from the mean.
         $revTime = $iteration->getResult()->getTime() / $iteration->getRevolutions();
         $zValue = $this->stats['stdev'] ? ($revTime - $this->stats['mean']) / $this->stats['stdev'] : 0;
         $iteration->setZValue($zValue);
         if (null !== $this->rejectionThreshold) {
             if (abs($deviation) >= $this->rejectionThreshold) {
                 $this->rejects[] = $iteration;
             }
         }
     }
     $this->computed = true;
 }
Exemplo n.º 2
0
 /**
  * @dataProvider provideKdeMode
  */
 public function testKdeMode($population, $space, $bandwidth, $expected)
 {
     $result = Statistics::kdeMode($population, $space, $bandwidth);
     $this->assertEquals($expected, round($result, 2));
 }
Exemplo n.º 3
0
 /**
  * Return the mode time.
  *
  * @return float
  */
 public function getModeTime()
 {
     return Statistics::kdeMode($this->getTimes());
 }