Download the PHP package square1/laravel-collection-rolling-average without Composer

On this page you can find all versions of the php package square1/laravel-collection-rolling-average. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-collection-rolling-average

Build and Test

Add Rolling Average Functionality To Collections

This package adds a rolling average functionality to Laravel's Collection facade. Rolling averages (also known as moving averages) are a statistic to capture the average change in a data range over time. For example, looking at a graph of daily temperature, or stock market movement, the graph may appear very noisy and erratic. The graph can be smoothed out to show longer-term trends by replacing each daily data point with an average of the previous N days.

Rolling Average graph

Take this example, where we want the rolling average of the last 5 days Day Value Rolling Average
1 5 5
2 7 6
3 3 5
4 5 5
5 10 6
6 3 5.6
7 5 5.2

This is a rolling average of all values in the set. While we want the rolling average of the latest 5 in this example, where there are less than 5 entries, the average is over the available entries.

It's possible to force this function to be more strict, and only start calculating the average once we have the minimum number of entries we want (5, in this case). This would mean that the resulting data changes a bit: Day Value Rolling Average
1 5 -
2 7 -
3 3 -
4 5 -
5 10 6
6 3 5.6
7 5 5.2

Install

Via Composer

The package will be automatically registered.

Versioning

This package is built on top of the collections in Illuminate\Support. With the release of 12.0.0, this package follows the version constraints of Illuminate\Support, which itself mirrors Laravel's release versioning.

Support for earlier versions prior to this change is listed in the table below.

Package Version Laravel Version
12.* 12
2.0.0 11, 10, 9, 8.7
1.0.0 10, 9, 8.7

Usage

Rolling average

This will show an average of all entries to date. Each returned value shall be the average of all values up to that point in the collection. This can mean that the early values retain some of their "noisiness", before the average really kicks in.

Rolling average with a limit

Calculate the rolling average based on the N previous entries to each data point. The collection returned will be the same size as the one supplied. This means that for positions in the collection before N values have been seen, the rolling average is the average of all values seen to date. If you want to exclude all values before N entries, take a look at the Rolling average with limited lookback section.

Rolling average with limited lookback

By default the package will return a collection with the same number of values supplied to it. This can lead to some noisiness at the start of the collection. For example, if we hav a dataset of 30 entries, and want a rolling average over the last 5 values, the first 4 values will be averages of the first N values, where N < 5. To avoid this, the parameter $includeAll can be set to false. This will return a collection with fewer results than the original. This will remove the noisiness from the start of the collection, but will mean a mismatch in the number of values returned.

Original Average (default) Average (limited lookback)
1 1 -
2 1.5 -
3 2 -
4 2.5 2.5
5 3.5 3.5
6 4.5 4.5

Apply weightings

Add weightings to increase or decrease the relevance of the most recent entries.

Tests

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-collection-rolling-average with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
laravel/framework Version ^12.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package square1/laravel-collection-rolling-average contains the following files

Loading the files please wait ....