• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

markrogoyski / math-php / 21585310639

02 Feb 2026 09:52AM UTC coverage: 99.457% (-0.2%) from 99.66%
21585310639

Pull #488

github

web-flow
Merge 1a4d42436 into c064e80bf
Pull Request #488: Add multilinear regression

72 of 84 new or added lines in 6 files covered. (85.71%)

7 existing lines in 3 files now uncovered.

8615 of 8662 relevant lines covered (99.46%)

223.36 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

80.0
/src/Statistics/Regression/Multilinear.php
1
<?php
2

3
namespace MathPHP\Statistics\Regression;
4

5
use MathPHP\Exception;
6
use MathPHP\Exception\BadDataException;
7

8
class Multilinear extends ParametricRegression
9
{
10
    use Methods\LeastSquares;
11
    use Models\MultilinearModel;
12

13
    /**
14
     * Calculates the regression parameters.
15
     *
16
     * @throws Exception\BadDataException
17
     * @throws Exception\IncorrectTypeException
18
     * @throws Exception\MatrixException
19
     * @throws Exception\MathException
20
     */
21
    public function calculate(): void
22
    {
23
        $this->parameters = $this->leastSquares($this->ys, $this->xss)->getColumn(0);
6✔
24
    }
25

26
    /**
27
     * Evaluate the regression equation at x.
28
     *
29
     * @param float $x
30
     *
31
     * @return float
32
     *
33
     * @throws BadDataException
34
     */
35
    public function evaluate(float $x): float
36
    {
37
        throw new Exception\BadDataException('Multilinear regression does not support evaluate(x)');
1✔
38
    }
39

40
    /**
41
     * Evaluate the regression equation at x vector.
42
     * Uses the instance model's evaluateModel method.
43
     *
44
     * @param non-empty-list<float> $vector
45
     *
46
     * @return float
47
     *
48
     * @throws BadDataException
49
     */
50
    public function evaluateVector(array $vector): float
51
    {
52
        if (empty($this->parameters)) {
2✔
NEW
53
            throw new Exception\BadDataException('Regression parameters are not calculated');
×
54
        }
55
        return $this->evaluateModel($vector, $this->parameters);
2✔
56
    }
57
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc