MediaWiki  1.23.2
RunningStat Class Reference

Represents a running summary of a stream of numbers. More...

Inheritance diagram for RunningStat:
Collaboration diagram for RunningStat:

Public Member Functions

 count ()
 Count the number of accumulated values. More...
 
 getMean ()
 Get the mean, or expected value. More...
 
 getStdDev ()
 Get the estimated stanard deviation. More...
 
 getVariance ()
 Get the estimated variance. More...
 
 merge (RunningStat $other)
 Merge another RunningStat instance into this instance. More...
 
 push ( $x)
 Add a number to the data set. More...
 

Public Attributes

float $m1 = 0.0
 The first moment (or mean, or expected value). More...
 
float $m2 = 0.0
 The second central moment (or variance). More...
 
float $max = NEGATIVE_INF
 The most value in the set. More...
 
float $min = INF
 The least value in the the set. More...
 
int $n = 0
 Number of samples. More...
 

Detailed Description

Represents a running summary of a stream of numbers.

RunningStat instances are accumulator-like objects that provide a set of continuously-updated summary statistics for a stream of numbers, without requiring that each value be stored. The measures it provides are the arithmetic mean, variance, standard deviation, and extrema (min and max); together they describe the central tendency and statistical dispersion of a set of values.

One RunningStat instance can be merged into another; the resultant RunningStat has the state it would have had if it had accumulated each individual point. This allows data to be summarized in parallel and in stages without loss of fidelity.

Based on a C++ implementation by John D. Cook: http://www.johndcook.com/standard_deviation.html http://www.johndcook.com/skewness_kurtosis.html

The in-line documentation for this class incorporates content from the English Wikipedia articles "Variance", "Algorithms for calculating variance", and "Standard deviation".

Since
1.23

Definition at line 52 of file RunningStat.php.

Member Function Documentation

◆ count()

RunningStat::count ( )

Count the number of accumulated values.

Returns
int Number of values

Definition at line 68 of file RunningStat.php.

References $n.

◆ getMean()

RunningStat::getMean ( )

Get the mean, or expected value.

The arithmetic mean is the sum of all measurements divided by the number of observations in the data set.

Returns
float Mean

Definition at line 98 of file RunningStat.php.

References $m1.

◆ getStdDev()

RunningStat::getStdDev ( )

Get the estimated stanard deviation.

The standard deviation of a statistical population is the square root of its variance. It shows shows how much variation from the mean exists. In addition to expressing the variability of a population, the standard deviation is commonly used to measure confidence in statistical conclusions.

Returns
float Estimated standard deviation

Definition at line 133 of file RunningStat.php.

References getVariance().

◆ getVariance()

RunningStat::getVariance ( )

Get the estimated variance.

Variance measures how far a set of numbers is spread out. A small variance indicates that the data points tend to be very close to the mean (and hence to each other), while a high variance indicates that the data points are very spread out from the mean and from each other.

Returns
float Estimated variance

Definition at line 112 of file RunningStat.php.

References n.

Referenced by getStdDev().

◆ merge()

RunningStat::merge ( RunningStat  $other)

Merge another RunningStat instance into this instance.

This instance then has the state it would have had if all the data had been accumulated by it alone.

Parameters
RunningStatRunningStat instance to merge into this one

Definition at line 145 of file RunningStat.php.

References $m1, $n, and n.

◆ push()

RunningStat::push (   $x)

Add a number to the data set.

Parameters
int | float$xValue to add

Definition at line 76 of file RunningStat.php.

References $m1, $n, and n.

Member Data Documentation

◆ $m1

float RunningStat::$m1 = 0.0

The first moment (or mean, or expected value).

**

Definition at line 56 of file RunningStat.php.

Referenced by getMean(), merge(), and push().

◆ $m2

float RunningStat::$m2 = 0.0

The second central moment (or variance).

**

Definition at line 58 of file RunningStat.php.

◆ $max

float RunningStat::$max = NEGATIVE_INF

The most value in the set.

**

Definition at line 62 of file RunningStat.php.

◆ $min

float RunningStat::$min = INF

The least value in the the set.

**

Definition at line 60 of file RunningStat.php.

◆ $n

int RunningStat::$n = 0

Number of samples.

**

Definition at line 54 of file RunningStat.php.

Referenced by count(), merge(), and push().


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