PHPackages                             revisor/trend - 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. revisor/trend

ActiveLibrary

revisor/trend
=============

Analyze data and try to find a significant trend

0.1.0(9y ago)333MITPHPPHP &gt;=5.5.0

Since Jan 11Pushed 9y ago2 watchersCompare

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

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

Trend Calculator
================

[](#trend-calculator)

[![Latest Version on Packagist](https://camo.githubusercontent.com/d33b351f93fecb973d66412b7f59d864a5230eb63830b9559fffc95b4a0d164e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f52657669736f722f7472656e642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/Revisor/trend)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/5548e919914fca46ffd89e5b85b5cfef1a2db4ea2e4af45f799b879f7eae3962/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f52657669736f722f7472656e642f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/Revisor/trend)[![Quality Score](https://camo.githubusercontent.com/48e35b1feeb7d7bf3a52776e59f7fcc5b99d8a0030eacd13be1e0a703c0cb85a/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f52657669736f722f7472656e642e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/Revisor/trend)[![Coverage Status](https://camo.githubusercontent.com/3ff7f2400683dec404db9eefd7fa7ee8a95ae63edfa61216caba74478381fc0a/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f52657669736f722f7472656e642e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/Revisor/trend/code-structure)[![Total Downloads](https://camo.githubusercontent.com/835d9af273987909b9c28de3e82f7f8ea6ef822508b69b93dd3f0cc8edf0a9b3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f52657669736f722f7472656e642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/Revisor/trend)

Analyze data and try to find a significant trend.

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

[](#introduction)

Imagine you're looking at points in a graph and you want to draw a single line through the points that represents their change. This is what Trend Calculator does. It tells you if there is a line through the points and how steep it is.

[![An example of linear regression](https://camo.githubusercontent.com/a442c77063c96acf1c95093bc8fe36d8a867734b7a8e405f17b6414e5f32f1d9/687474703a2f2f77696b692e6177662e666f7273742e756e692d676f657474696e67656e2e64652f77696b692f696d616765732f7468756d622f312f31362f322e382e322d66696733322e706e672f33303070782d322e382e322d66696733322e706e67)](https://camo.githubusercontent.com/a442c77063c96acf1c95093bc8fe36d8a867734b7a8e405f17b6414e5f32f1d9/687474703a2f2f77696b692e6177662e666f7273742e756e692d676f657474696e67656e2e64652f77696b692f696d616765732f7468756d622f312f31362f322e382e322d66696733322e706e672f33303070782d322e382e322d66696733322e706e67)

This class takes as an input a series of data points in time, performs regression, determines its statistical significance and returns a trend.

Time is the independent/explanatory variable, values are the dependent/outcome/target variable. In simplest terms:

"How does value change in time?"

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

[](#installation)

Install Trend Calculator with the PHP package manager, [Composer](https://getcomposer.org/):

```
composer require revisor/trend
```

Usage
-----

[](#usage)

```
$trendCalculator = new TrendCalculator();

/**
 * $data is an array of arrays
 * In the inner arrays, keys are a time value in any unit (seconds, ie.
 * timestamp, microseconds, days, weeks...), the values are data values.
 * Multiple values for one point in time are allowed - maybe two events
 * occurred at one time.
 */
$data = [
    [1 => 9],
    [1 => 5],
    [2 => 12],
    [4 => 7]
];

/**
 * The resulting trend is a negative or positive float, or zero.
 *
 * Values other than zero mean that there is a significant trend in the provided
 * data, and the trend goes down (for a negative number) or up (for a positive number).
 *
 * If the value is zero, it means that there is no significant trend.
 */
$trend = $trendCalculator->calculateTrend($data);
```

The slope of the trend is calculated by [`mcordingley/Regression`](https://github.com/mcordingley/Regression). You can access more information about your data by asking the regression itself.

```
$regression = $trendCalculator->getRegression();
var_dump($regression->getStandardErrorCoefficients());
```

Change log
----------

[](#change-log)

Please see the [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

License
-------

[](#license)

The MIT License (MIT). Please see the [License](LICENSE.md) for more information.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity48

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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3406d ago

### Community

Maintainers

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

---

Top Contributors

[![Revisor](https://avatars.githubusercontent.com/u/550341?v=4)](https://github.com/Revisor "Revisor (2 commits)")

---

Tags

regressionsignificancecorrelationtrend

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/revisor-trend/health.svg)

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

###  Alternatives

[rubix/ml

A high-level machine learning and deep learning library for the PHP language.

2.2k1.4M28](/packages/rubix-ml)[mcordingley/regression

Regression Package for PHP

89119.3k1](/packages/mcordingley-regression)[dr-que/polynomial-regression

Calculates and returns coefficients for polynomial regression.

22214.6k3](/packages/dr-que-polynomial-regression)[denissimon/prediction-builder

A library for machine learning that builds predictions using a linear regression.

1146.7k](/packages/denissimon-prediction-builder)[andreekeberg/abby

🙋‍♀️ Minimal A/B Testing Library

3210.3k](/packages/andreekeberg-abby)

PHPackages © 2026

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