RunningStat
PHP implementations of online statistical algorithms
Loading...
Searching...
No Matches
Wikimedia\PSquare Class Reference

Represents a running, online estimate of a p-quantile for a series of observations using the P-squared algorithm. More...

Public Member Functions

 __construct ( $p=0.5)
 
 __serialize ()
 Export state, e.g.
 
 __unserialize (array $data)
 
 getCount ()
 Get the total number of accumulated observations.
 
 addObservation ( $x)
 Add an observation.
 
 getValue ()
 Get the estimated p-quantile value.
 

Detailed Description

Represents a running, online estimate of a p-quantile for a series of observations using the P-squared algorithm.

The algorithm is from "The P-Square Algorithm for Dynamic Calculation of Percentiles and Histograms without Storing Observations," Communications of the ACM, October 1985 by R. Jain and I. Chlamtac.

Constructor & Destructor Documentation

◆ __construct()

Wikimedia\PSquare::__construct ( $p = 0.5)
Parameters
float$pthe percentile (defaults to 0.5, or median).

Member Function Documentation

◆ __serialize()

Wikimedia\PSquare::__serialize ( )

Export state, e.g.

for serializing and caching.

Returns
array

◆ __unserialize()

Wikimedia\PSquare::__unserialize ( array $data)
Parameters
array$data

◆ addObservation()

Wikimedia\PSquare::addObservation ( $x)

Add an observation.

Parameters
int | float$xValue to add

◆ getCount()

Wikimedia\PSquare::getCount ( )

Get the total number of accumulated observations.

Returns
int

◆ getValue()

Wikimedia\PSquare::getValue ( )

Get the estimated p-quantile value.

Returns
float

The documentation for this class was generated from the following file: