PHPackages                             magaras/pstats - 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. magaras/pstats

ActiveLibrary

magaras/pstats
==============

Library that contains statistical methods.

1.2.1(3y ago)16.3kMITPHPPHP ^5.4.0 || ^7.0

Since Aug 4Pushed 3y ago1 watchersCompare

[ Source](https://github.com/magaras/pstats)[ Packagist](https://packagist.org/packages/magaras/pstats)[ RSS](/packages/magaras-pstats/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (2)Versions (6)Used By (0)

pStats
======

[](#pstats)

[![Build Status](https://camo.githubusercontent.com/40dc1bb0b0020912314556eb2a55f17b670fb9ddfb76bbfb38db3674583f3443/68747470733a2f2f7472617669732d63692e6f72672f6d6167617261732f7073746174732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/magaras/pstats)

A PHP library containing a lot of statistical methods, from the most usefull ones (*like mean and variance*) to even some more sophisticated, like moving average and outliers around median.

I intend to keep updating this library in order for it to be as thorough as possible.

Install with composer `composer require magaras/pstats`.

The library supports the following methods:
===========================================

[](#the-library-supports-the-following-methods)

**Mean**

```
Basic::mean($data);
```

\*\* Median\*\*

```
Basic::median($data);
```

**Mode**

```
Basic::mode($data);
```

**Range**

```
Basic::range($data);
```

**Percentage Change**

```
Basic::percentageChange($start_value, $end_value);
```

**Percentage Difference**

```
Basic::percentageDifference($start_value, $end_value);
```

**Absolute Error**

```
Error::absoluteError(0, 0);
```

**Mean Absolute Error**

```
Error::mae($actuals, $predictions);
```

**Mean Square Error**

```
Error::mse($actuals, $predictions);
```

**Variance *(population / sample)***

```
Error::variance($data, true);
Error::variance($data, false);
```

**Std**

```
Error::std($data);
```

**Absolute / Relative / Cumulative Frequency for continuous values**

```
$frequency_classes = Frequency::frequencyContinuous($data);

$frequency_classes[$i]->absolute_frequency

$frequency_classes[$i]->relative_frequency

$frequency_classes[$i]->cumulative_frequency
```

**Absolute / Relative / Cumulative Frequency for discrete values**

```
$frequency_classes = Frequency::frequencyDiscrete($data);

$frequency_classes[$i]->absolute_frequency

$frequency_classes[$i]->relative_frequency

$frequency_classes[$i]->cumulative_frequency
```

**Simple Moving Average**

```
MovingAverage::simpleMovingAverage($moving_average_value, $data);
```

**Exponential Moving Average**

```
MovingAverage::exponentialMovingAverage(moving_average_value, $data);
```

**Outliers Around Mean**

```
Outliers::outlierAroundMean($data);
```

**Outliers Around Median**

```
Outliers::outlierAroundMedian($data);
```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 92.3% of commits — single point of failure

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 ~558 days

Total

5

Last Release

1332d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/70a2bfbc5f1a64c0879022402f67fb80ebc02f621c61365b14da18e5e91ea4f9?d=identicon)[magaras](/maintainers/magaras)

---

Top Contributors

[![magaras](https://avatars.githubusercontent.com/u/5760786?v=4)](https://github.com/magaras "magaras (12 commits)")[![shmax](https://avatars.githubusercontent.com/u/773172?v=4)](https://github.com/shmax "shmax (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/magaras-pstats/health.svg)

```
[![Health](https://phpackages.com/badges/magaras-pstats/health.svg)](https://phpackages.com/packages/magaras-pstats)
```

###  Alternatives

[timacdonald/log-fake

A drop in fake logger for testing with the Laravel framework.

4235.9M56](/packages/timacdonald-log-fake)[jasonmccreary/laravel-test-assertions

A set of helpful assertions when testing Laravel applications.

3513.9M32](/packages/jasonmccreary-laravel-test-assertions)[ergebnis/phpunit-slow-test-detector

Provides facilities for detecting slow tests in phpunit/phpunit.

1468.1M72](/packages/ergebnis-phpunit-slow-test-detector)[typo3/testing-framework

The TYPO3 testing framework provides base classes for unit, functional and acceptance testing.

675.0M774](/packages/typo3-testing-framework)[robiningelbrecht/phpunit-pretty-print

Prettify PHPUnit output

76460.0k15](/packages/robiningelbrecht-phpunit-pretty-print)[webmozarts/strict-phpunit

Enables type-safe comparisons of objects in PHPUnit

31252.7k5](/packages/webmozarts-strict-phpunit)

PHPackages © 2026

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