src/Regression/LogarithmicRegression.php 1 location
|
@@ 51-54 (lines=4) @@
|
| 48 |
|
|
| 49 |
|
$A = ($this->sumIndex[2] - $B * $this->sumIndex[0]) / $k; |
| 50 |
|
|
| 51 |
|
foreach ($this->sourceSequence as $i => $val) { |
| 52 |
|
$coordinate = [$val[0], $A + $B * log($val[0])]; |
| 53 |
|
$this->resultSequence[] = $coordinate; |
| 54 |
|
} |
| 55 |
|
|
| 56 |
|
$this->equation = sprintf('y = %s + %s ln(x)', round($A, 2), round($B, 2)); |
| 57 |
|
|
src/Regression/LinearRegression.php 1 location
|
@@ 54-57 (lines=4) @@
|
| 51 |
|
|
| 52 |
|
$intercept = $this->sumIndex[1] / $k - $gradient * $this->sumIndex[0] / $k; |
| 53 |
|
|
| 54 |
|
foreach ($this->sourceSequence as $i => $val) { |
| 55 |
|
$coordinate = [$val[0], $val[0] * $gradient + $intercept]; |
| 56 |
|
$this->resultSequence[] = $coordinate; |
| 57 |
|
} |
| 58 |
|
|
| 59 |
|
$this->equation = sprintf('y = %sx + %s', round($gradient, 1), round($intercept, 1)); |
| 60 |
|
|
src/Regression/ExponentialRegression.php 1 location
|
@@ 52-55 (lines=4) @@
|
| 49 |
|
$A = exp(($this->sumIndex[2] * $this->sumIndex[3] - $this->sumIndex[5] * $this->sumIndex[4]) / $denominator); |
| 50 |
|
$B = ($this->sumIndex[1] * $this->sumIndex[4] - $this->sumIndex[5] * $this->sumIndex[3]) / $denominator; |
| 51 |
|
|
| 52 |
|
foreach ($this->sourceSequence as $i => $val) { |
| 53 |
|
$coordinate = [$val[0], $A * exp($B * $val[0])]; |
| 54 |
|
$this->resultSequence[] = $coordinate; |
| 55 |
|
} |
| 56 |
|
|
| 57 |
|
$this->equation = sprintf('y = %s+ e^(%sx)', round($A, 2), round($B, 2)); |
| 58 |
|
|