/**
  * @throws RegressionException
  */
 public function testCalculate()
 {
     $linear = new ExponentialRegression();
     $linear->setSourceSequence($this->rows[0]);
     $linear->calculate();
     /** @var RegressionModel $regressionModel */
     $regressionModel = $linear->getRegressionModel();
     $this->assertEquals('y = 30.2+ e^(0.39x)', $regressionModel->getEquation());
     $this->assertEquals(1470, round($regressionModel->getResultSequence()[9][1]));
     $this->assertEquals(997, round($regressionModel->getResultSequence()[8][1]));
     $this->assertEquals(676, round($regressionModel->getResultSequence()[7][1]));
     $regressionModel = RegressionFactory::exponential($this->rows[1]);
     $this->assertEquals('y = 12.36+ e^(0.02x)', $regressionModel->getEquation());
     $this->assertEquals(13, round($regressionModel->getResultSequence()[0][1]));
     $this->assertEquals(13, round($regressionModel->getResultSequence()[1][1]));
     $this->assertEquals(13, round($regressionModel->getResultSequence()[2][1]));
 }
Exemplo n.º 2
0
$linear = new LinearRegression();
$linear->setSourceSequence($testData);
$linear->calculate();
/** @var RegressionModel $regressionModel */
$regressionModel = $linear->getRegressionModel();
/**
 * Calculate with Fabric method
 */
/** @var RegressionModel $regressionModel */
$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()