PHP Class PhpBench\Math\Statistics

Show file Open project: dantleech/phpbench Class Usage Examples

Public Methods

Method Description
histogram ( array $values, integer $steps = 10, float $lowerBound = null, float $upperBound = null ) : array Generate a histogram.
kdeMode ( array $population, integer $space = 512, float $bandwidth = null ) : float[] Return the mode using the kernel density estimator using the normal distribution.
linspace ( float $min, float $max, integer $num = 50, boolean $endpoint = true ) : float[] Return an array populated with $num numbers from $min to $max.
mean ( array $values ) : mixed Return the mean (average) value of the given values.
stdev ( array $values, boolean $sample = false ) : float Return the standard deviation of a given population.
variance ( array $values, boolean $sample = false ) : float Return the variance for a given population.

Method Details

histogram() public static method

Note this is not a great function, and should not be relied upon for serious use. For a better implementation copy: http://docs.scipy.org/doc/numpy-1.10.1/reference/generated/numpy.histogram.html
public static histogram ( array $values, integer $steps = 10, float $lowerBound = null, float $upperBound = null ) : array
$values array
$steps integer
$lowerBound float
$upperBound float
return array

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[]

linspace() public static method

Return an array populated with $num numbers from $min to $max.
public static linspace ( float $min, float $max, integer $num = 50, boolean $endpoint = true ) : float[]
$min float
$max float
$num integer
$endpoint boolean
return float[]

mean() public static method

Return the mean (average) value of the given values.
public static mean ( array $values ) : mixed
$values array
return mixed

stdev() public static method

Return the standard deviation of a given population.
public static stdev ( array $values, boolean $sample = false ) : float
$values array
$sample boolean
return float

variance() public static method

Return the variance for a given population.
public static variance ( array $values, boolean $sample = false ) : float
$values array
$sample boolean
return float