/**
  * @throws RegressionException
  */
 public function testCalculate()
 {
     $linear = new LogarithmicRegression();
     $linear->setSourceSequence($this->rows[0]);
     $linear->calculate();
     /** @var RegressionModel $regressionModel */
     $regressionModel = $linear->getRegressionModel();
     $this->assertEquals('y = -320.03 + 504.51ln(x)', $regressionModel->getEquation());
     $this->assertEquals(842, round($regressionModel->getResultSequence()[9][1]));
     $this->assertEquals(788, round($regressionModel->getResultSequence()[8][1]));
     $this->assertEquals(729, round($regressionModel->getResultSequence()[7][1]));
     $regressionModel = RegressionFactory::logarithmic($this->rows[1]);
     $this->assertEquals('y = 11.73 + 1.43ln(x)', $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]));
 }
예제 #2
0
$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));