PHPackages                             wells5609/php-math - 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. wells5609/php-math

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

wells5609/php-math
==================

Math functions for PHP.

3834PHP

Since Aug 20Pushed 11y ago1 watchersCompare

[ Source](https://github.com/wells5609/PHP-Math)[ Packagist](https://packagist.org/packages/wells5609/php-math)[ RSS](/packages/wells5609-php-math/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

PHP-Math
========

[](#php-math)

PHP math functions: mean(), median(), variance(), covariance(), correlation(), stddev(), pv(), npv(), and more.

\#Functions

\##`mean(array $values)`

**Parameters:**

- `Array $values` - Array of numeric values.

**Returns:** `String` Arithmetic average of the given values.

**Alias:** `avg()`

\##`median(array $values)`

**Parameters:**

- `Array $values` - Array of numeric values

**Returns:** `String` Median value of the given values, or null if it cannot be computed.

\##`sumxy(array $x_values, array $y_values)`

**Parameters:**

- `Array $x_values` - Array of numeric values of x.
- `Array $y_values` - Array of numeric values of y.

**Returns:** `String` Sum of the products of the values.

\##`sos(array $values, $values2 = null)`

**Parameters:**

- `Array $values` - Array of numeric values.
- `Null|Array|String $values2` - Optional - If null, simply sums the square of each array value. If given a scalar value, sums the squares of the difference between each array value and that given by $values2 (good for explained/regression SS). If given an array, sums the squares of the difference between betweeen each array value and the value in $values2 with matching key (good for residual SS).

**Returns:** `String` Sum of squares.

\##`variance(array $values, $is_sample = false)`

**Returns:** `String` Variance

\##`stddev(array $a, $is_sample = false)`

**Returns:** `String` Standard deviation

**Alias:** `stdev()`

\##`covariance(array $x_values, array $y_values)`

**Returns:** `String` Covariance

**Alias:** `covar()`

\##`correlation(array $x_values, array $y_values)`

**Returns:** `String` Correlation

**Alias:** `correl()`

\##`pv($cashflow, $rate, $period = 0)`

**Returns:** `String` Present value

\##`npv(array $cashflows, $rate)`

**Returns:** `String` Net present value

\##`weighted_avg(array $values, array $weights)`

**Returns:** `String` Weighted average

\##`pct($portion, $total)`

**Returns:** `String` Percent

\##`pct_change($current, $previous)`

**Returns:** `String` Percent change

\##`pct_change_array(array $values)`

**Returns:** `Array` Array values percent change

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/2b5b7d38d1408fa7abf81c2650415faa6d135c0725b5a25c5e52aefeac03c455?d=identicon)[wells5609](/maintainers/wells5609)

---

Top Contributors

[![wells5609](https://avatars.githubusercontent.com/u/4088444?v=4)](https://github.com/wells5609 "wells5609 (16 commits)")

### Embed Badge

![Health badge](/badges/wells5609-php-math/health.svg)

```
[![Health](https://phpackages.com/badges/wells5609-php-math/health.svg)](https://phpackages.com/packages/wells5609-php-math)
```

###  Alternatives

[dnoegel/php-xdg-base-dir

implementation of xdg base directory specification for php

6.3k239.4M16](/packages/dnoegel-php-xdg-base-dir)[thiagoalessio/tesseract_ocr

A wrapper to work with Tesseract OCR inside PHP.

3.0k3.3M25](/packages/thiagoalessio-tesseract-ocr)[pyrech/composer-changelogs

Display changelogs after each composer update

5904.0M25](/packages/pyrech-composer-changelogs)[mark-gerarts/auto-mapper-plus

An AutoMapper for PHP

5623.2M21](/packages/mark-gerarts-auto-mapper-plus)[wamania/php-stemmer

Native PHP Stemmer

1434.0M33](/packages/wamania-php-stemmer)[geocoder-php/plugin

Plugins to Geocoder providers

705.1M2](/packages/geocoder-php-plugin)

PHPackages © 2026

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