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

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

truesocialmetrics/math
======================

php standard math algorithms: running average, linear interpolation, derivative, local extremum

1.2.0(7y ago)26.8k↓50%2MITPHPPHP &gt;=7.1

Since Mar 23Pushed 7y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (11)Used By (0)

tt-math
=======

[](#tt-math)

[![Build Status](https://camo.githubusercontent.com/8e794b37fced26815c7522830704125a0394581d194b38e5d8d52f8dcde1f2e3/68747470733a2f2f7472617669732d63692e6f72672f6e6563726f6d616e74323030352f74742d6d6174682e737667)](https://travis-ci.org/necromant2005/tt-math)

Introduction
------------

[](#introduction)

Standard Math Algorithms: Running Average, Linear Interpolation

Features / Goals
----------------

[](#features--goals)

- Simple functional API
- Implementation Running Average with custom window size
- Implementation Running Average with custom window size and Edge binding
- Implementation Linear interpolation
- Implementation Derivative
- Implementation Local Extremum

Installation
------------

[](#installation)

### Main Setup

[](#main-setup)

#### With composer

[](#with-composer)

1. Add this to your composer.json:

```
"require": {
    "necromant2005/tt-math": "1.*",
}
```

2. Now tell composer to download TweeMath PHP SDK by running the command:

```
$ php composer.phar update
```

#### Usage

[](#usage)

Running average using with window size = 2

```
use TweeMath\Algorithm;

Algorithm\RunningAverage(array(0 => 0, 1 => 2, 3 => 3, 4 => 5, 5 => 3, 6 => 1), 2);
// array(1 => 1,  4 => 4, 6 => 2)
```

Running average using with window size = 2 and edges binding

```
use TweeMath\Algorithm;

Algorithm\RunningAverageEdge(array(0 => 0, 1 => 2, 3 => 3, 4 => 5, 5 => 3), 2);
// array(0 => 0, 1 => 1,  4 => 4, 5 => 3)
```

Linear interpolation for the next point x=2

```
use TweeMath\Algorithm;

Algorithm\LinearInterpolation(array(0 => 0, 1 => 1), 2); // 2
```

Linear interpolation for large numbers for the next point max + 2

```
use TweeMath\Algorithm;

$max = (PHP_MAX_INT >> 1)  + 1000;
Algorithm\LinearInterpolationGracefull(array(time() => $max, time() + 1 => $max + 1), time() + 2); // $max + 2
```

Derivative for input with epsilon = 1

```
use TweeMath\Algorithm;

Algorithm\Derivative(array(0 => 0, 1 => 2, 4 => 5, 6 => 1), 1);
// array(0 => 2, 1 => 3, 4 => -5)
```

Local Extremum's for input with epsilon = 1

```
use TweeMath\Algorithm;

Algorithm\LocalExtremum(array(0 => 0, 1 => 2, 2 => 4,  3 => 3, 4 => 5, 5 => 3, 6 => 1), 1);
// array(2 => -1, 3 => 2, 4 => -2)
```

###  Health Score

33

—

LowBetter than 74% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity64

Established project with proven stability

 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.

###  Release Activity

Cadence

Every ~193 days

Recently: every ~435 days

Total

10

Last Release

2689d ago

PHP version history (2 changes)1.0PHP &gt;=5.3.0

1.2.0PHP &gt;=7.1

### Community

Maintainers

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

---

Top Contributors

[![necromant2005](https://avatars.githubusercontent.com/u/159874?v=4)](https://github.com/necromant2005 "necromant2005 (21 commits)")

---

Tags

mathrunning averagelinear interpolationderivativelocal extremum

### Embed Badge

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

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

###  Alternatives

[brick/math

Arbitrary-precision arithmetic library

2.1k504.0M276](/packages/brick-math)[markrogoyski/math-php

Math Library for PHP. Features descriptive statistics and regressions; Continuous and discrete probability distributions; Linear algebra with matrices and vectors, Numerical analysis; special mathematical functions; Algebra

2.4k7.1M40](/packages/markrogoyski-math-php)[phpseclib/bcmath_compat

PHP 5.x-8.x polyfill for bcmath extension

16720.7M16](/packages/phpseclib-bcmath-compat)[rubix/tensor

A library and extension that provides objects for scientific computing in PHP.

2751.4M5](/packages/rubix-tensor)[jlawrence/eos

Parse and solve math equations without using 'eval()'.

1071.1M11](/packages/jlawrence-eos)[php-decimal/php-decimal

Correctly-rounded arbitrary precision decimal floating point

781.0M9](/packages/php-decimal-php-decimal)

PHPackages © 2026

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