Add RunningStat class, tests
authorOri Livneh <ori@wikimedia.org>
Tue, 31 Dec 2013 06:42:34 +0000 (22:42 -0800)
committerTyler Anthony Romeo <tylerromeo@gmail.com>
Tue, 31 Dec 2013 19:45:58 +0000 (14:45 -0500)
commit766c11b51669030ff5728d716b4683085fc21057
tree64c58a9192a89f94b21f88ae0fb2dce389d5ee3c
parent331bb31f477d1d40f51991cdaccf07a35dc2502b
Add RunningStat class, tests

RunningStat computes the central tendency, shape, and extrema of a set of
points online, in constant space. It uses a neat one-pass algorithm for
calculating variance, described here:
  <en.wikipedia.org/wiki/Algorithms_for_calculating_variance#On-line_algorithm>

This particular implementation adapts a sample C++ implementation by John D.
Cook to PHP. See <http://www.johndcook.com/standard_deviation.html> and
  <http://www.johndcook.com/skewness_kurtosis.html>.

RunningStat instances can be combined. The resultant RunningStat has the same
state it would have had if it had been used to accumulate each point. This
property is attractive because it allows separate threads of execution to
process a stream in parallel. More importantly, individual points can be
accumulated in stages, without loss of fidelity, at intermediate points in the
aggregation process. JavaScript profiling samples can be accumulated in the
user's browser and be combined with measurements from other browsers on the
profiling data aggregator. Functions that are called multiple times in the
course of a profiled web request can be accumulated in MediaWiki prior to being
transmitted to the profiling data aggregator.

Usage will be introduced in a dependent commit.

Change-Id: Ifedda276dfe8e0783cb8c4a95626e2aedd4ad368
includes/AutoLoader.php
includes/profiler/RunningStat.php [new file with mode: 0644]
tests/phpunit/includes/RunningStatTest.php [new file with mode: 0644]