PHPackages                             wikimedia/running-stat - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. wikimedia/running-stat

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

wikimedia/running-stat
======================

PHP implementations of online statistical algorithms

v2.2.0(9mo ago)11859.6k↑29.9%21GPL-2.0-or-laterPHPPHP &gt;=8.1.0

Since Oct 27Pushed 1w ago14 watchersCompare

[ Source](https://github.com/wikimedia/RunningStat)[ Packagist](https://packagist.org/packages/wikimedia/running-stat)[ Docs](https://www.mediawiki.org/wiki/RunningStat)[ RSS](/packages/wikimedia-running-stat/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (8)Versions (8)Used By (1)

RunningStat
===========

[](#runningstat)

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: [https://en.wikipedia.org/wiki/Algorithms\_for\_calculating\_variance#On-line\_algorithm](https://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 also:

- [http://www.johndcook.com/standard\_deviation.html](http://www.johndcook.com/standard_deviation.html)
- [http://www.johndcook.com/skewness\_kurtosis.html](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
-----

[](#usage)

Here is how you use it:

```
use Wikimedia\RunningStat;

$rstat = new RunningStat();
foreach ( [
  49.7168, 74.3804,  7.0115, 96.5769, 34.9458,
  36.9947, 33.8926, 89.0774, 23.7745, 73.5154,
  86.1322, 53.2124, 16.2046, 73.5130, 10.4209,
  42.7299, 49.3330, 47.0215, 34.9950, 18.2914,
] as $sample ) {
  $rstat->addObservation( $sample );
}

printf(
  "n = %d; min = %.2f; max = %.2f; mean = %.2f; variance = %.2f; stddev = %.2f\n",
  count( $rstat ),
  $rstat->min,
  $rstat->max,
  $rstat->getMean(),
  $rstat->getVariance(),
  $rstat->getStdDev()
);
// Output:
// n = 20; min = 7.01; max = 96.58; mean = 47.59; variance = 725.71; stddev = 26.94
```

License
-------

[](#license)

GPL-2.0-or-later

###  Health Score

61

—

FairBetter than 99% of packages

Maintenance80

Actively maintained with recent releases

Popularity45

Moderate usage in the ecosystem

Community26

Small or concentrated contributor base

Maturity77

Established project with proven stability

 Bus Factor3

3 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~610 days

Recently: every ~716 days

Total

7

Last Release

286d ago

Major Versions

v1.2.1 → v2.0.02022-05-20

PHP version history (4 changes)v1.0.0PHP &gt;=5.3.3

v1.2.0PHP &gt;=5.5.9

v2.0.0PHP &gt;=7.2.0

v2.2.0PHP &gt;=8.1.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/b94d9718c06ec7c3fd7a104bc44966fb7464b9ec7411582343ea35a7a6a85f08?d=identicon)[mediawiki](/maintainers/mediawiki)

![](https://www.gravatar.com/avatar/716c86d71cbf921e7912a505f89d799de398fc0a3af0bd4c8862834b2d642bd7?d=identicon)[wikimedia](/maintainers/wikimedia)

---

Top Contributors

[![reedy](https://avatars.githubusercontent.com/u/67615?v=4)](https://github.com/reedy "reedy (13 commits)")[![jdforrester](https://avatars.githubusercontent.com/u/881572?v=4)](https://github.com/jdforrester "jdforrester (11 commits)")[![umherirrender](https://avatars.githubusercontent.com/u/1174884?v=4)](https://github.com/umherirrender "umherirrender (11 commits)")[![Krinkle](https://avatars.githubusercontent.com/u/156867?v=4)](https://github.com/Krinkle "Krinkle (6 commits)")[![legoktm](https://avatars.githubusercontent.com/u/81392?v=4)](https://github.com/legoktm "legoktm (6 commits)")[![atdt](https://avatars.githubusercontent.com/u/376462?v=4)](https://github.com/atdt "atdt (5 commits)")[![ricordisamoa](https://avatars.githubusercontent.com/u/4588496?v=4)](https://github.com/ricordisamoa "ricordisamoa (2 commits)")[![DannyS712](https://avatars.githubusercontent.com/u/46829944?v=4)](https://github.com/DannyS712 "DannyS712 (1 commits)")[![Ammarpad](https://avatars.githubusercontent.com/u/45658045?v=4)](https://github.com/Ammarpad "Ammarpad (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/wikimedia-running-stat/health.svg)

```
[![Health](https://phpackages.com/badges/wikimedia-running-stat/health.svg)](https://phpackages.com/packages/wikimedia-running-stat)
```

###  Alternatives

[usamamuneerchaudhary/commentify

Easy Laravel Livewire Comments with TailwindCSS UI

23216.2k](/packages/usamamuneerchaudhary-commentify)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
