You are here

public function PHPExcel_Polynomial_Best_Fit::getEquation in Loft Data Grids 6.2

Same name and namespace in other branches
  1. 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Shared/trend/polynomialBestFitClass.php \PHPExcel_Polynomial_Best_Fit::getEquation()

* Return the Equation of the best-fit line * *

Parameters

int $dp Number of places of decimal precision to display: * @return string *

Overrides PHPExcel_Best_Fit::getEquation

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Shared/trend/polynomialBestFitClass.php, line 104

Class

PHPExcel_Polynomial_Best_Fit
PHPExcel_Polynomial_Best_Fit

Code

public function getEquation($dp = 0) {
  $slope = $this
    ->getSlope($dp);
  $intersect = $this
    ->getIntersect($dp);
  $equation = 'Y = ' . $intersect;
  foreach ($slope as $key => $value) {
    if ($value != 0.0) {
      $equation .= ' + ' . $value . ' * X';
      if ($key > 0) {
        $equation .= '^' . ($key + 1);
      }
    }
  }
  return $equation;
}