/** * @throws RegressionException */ public function testCalculate() { $linear = new PowerRegression(); $linear->setSourceSequence($this->rows[0]); $linear->calculate(); /** @var RegressionModel $regressionModel */ $regressionModel = $linear->getRegressionModel(); $this->assertEquals('y = 7.52 + x^2.18', $regressionModel->getEquation()); $this->assertEquals(1126, round($regressionModel->getResultSequence()[9][1])); $this->assertEquals(895, round($regressionModel->getResultSequence()[8][1])); $this->assertEquals(693, round($regressionModel->getResultSequence()[7][1])); $regressionModel = RegressionFactory::power($this->rows[1]); $this->assertEquals('y = 11.69 + x^0.11', $regressionModel->getEquation()); $this->assertEquals(12, round($regressionModel->getResultSequence()[0][1])); $this->assertEquals(13, round($regressionModel->getResultSequence()[1][1])); $this->assertEquals(13, round($regressionModel->getResultSequence()[2][1])); }
$regressionModel = RegressionFactory::linear($testData); /** * Calculate Exponential regression call calculate() */ $exponential = new ExponentialRegression(); $exponential->setSourceSequence($testData); $exponential->calculate(); /** * And with Fabric method */ $regressionModel = $exponential->getRegressionModel(); /** * Calculate logarithmic regression call calculate() */ $logarithmic = new LogarithmicRegression(); $logarithmic->setSourceSequence($testData); $logarithmic->calculate(); /** @var RegressionModel $regressionModel */ $regressionModel = $logarithmic->getRegressionModel(); $regressionModel = RegressionFactory::logarithmic($testData); /** * Calculate power regression call calculate() */ $powerReg = new PowerRegression(); $powerReg->setSourceSequence($testData); $powerReg->calculate(); /** @var RegressionModel $regressionModel */ $regressionModel = $powerReg->getRegressionModel(); $regressionModel = RegressionFactory::power($testData); var_dump($regressionModel); //var_dump(RegressionFactory::Power($testData));