pipirima/trend-line-calculator

There is no license information available for the latest version (0.3.2) of this package.

Calculation of trend line parameters for a given set of chart points

0.3.2 2023-01-24 16:16 UTC

This package is auto-updated.

Last update: 2024-04-24 18:52:33 UTC


README

Calculation of trend line parameters for a given set of chart points.

Usage

use Pipirima\TrendLine\Calculator;

// ...

        // create points
        $points = [
            [1, 2],
            [2, 3],
            [3, 6],
            [4, 8],
            [5, 10],
            [6, 12],
        ];

        // calculate trend line
        $calculator = new Calculator();
        $line = $calculator->calculateLine($points);

        // check its coefficients
        $this->assertLessThan(0.0001, abs(2.0857 - $line[0]));
        $this->assertLessThan(0.0001, abs(-0.46667 - $line[1]));