Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
8 / 8 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
LogLogRegression | |
100.00% |
8 / 8 |
|
100.00% |
3 / 3 |
5 | |
100.00% |
1 / 1 |
getRegression | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
3 | |||
getSlope | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getElasticity | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | /** |
3 | * Jingga |
4 | * |
5 | * PHP Version 8.1 |
6 | * |
7 | * @package phpOMS\Math\Statistic\Forecast\Regression |
8 | * @copyright Dennis Eichhorn |
9 | * @license OMS License 2.0 |
10 | * @version 1.0.0 |
11 | * @link https://jingga.app |
12 | */ |
13 | declare(strict_types=1); |
14 | |
15 | namespace phpOMS\Math\Statistic\Forecast\Regression; |
16 | |
17 | use phpOMS\Math\Matrix\Exception\InvalidDimensionException; |
18 | |
19 | /** |
20 | * Regression class. |
21 | * |
22 | * @package phpOMS\Math\Statistic\Forecast\Regression |
23 | * @license OMS License 2.0 |
24 | * @link https://jingga.app |
25 | * @since 1.0.0 |
26 | */ |
27 | final class LogLogRegression extends RegressionAbstract |
28 | { |
29 | /** |
30 | * {@inheritdoc} |
31 | * |
32 | * @throws InvalidDimensionException |
33 | */ |
34 | public static function getRegression(array $x, array $y) : array |
35 | { |
36 | if (($c = \count($x)) !== \count($y)) { |
37 | throw new InvalidDimensionException($c . 'x' . \count($y)); |
38 | } |
39 | |
40 | for ($i = 0; $i < $c; ++$i) { |
41 | $x[$i] = \log($x[$i]); |
42 | $y[$i] = \log($y[$i]); |
43 | } |
44 | |
45 | return parent::getRegression($x, $y); |
46 | } |
47 | |
48 | /** |
49 | * {@inheritdoc} |
50 | */ |
51 | public static function getSlope(float $b1, float $y, float $x) : float |
52 | { |
53 | return $b1 * $y / $x; |
54 | } |
55 | |
56 | /** |
57 | * {@inheritdoc} |
58 | */ |
59 | public static function getElasticity(float $b1, float $y, float $x) : float |
60 | { |
61 | return $b1; |
62 | } |
63 | } |