public static function PHPExcel_Calculation_Statistical::FORECAST in Loft Data Grids 7.2
Same name and namespace in other branches
- 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Statistical.php \PHPExcel_Calculation_Statistical::FORECAST()
* FORECAST * * Calculates, or predicts, a future value by using existing values. The predicted value is a y-value for a given x-value. * *
Parameters
float Value of X for which we want to find Y: * @param array of mixed Data Series Y * @param array of mixed Data Series X * @return float
File
- vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Calculation/ Statistical.php, line 1556
Class
- PHPExcel_Calculation_Statistical
- PHPExcel_Calculation_Statistical
Code
public static function FORECAST($xValue, $yValues, $xValues) {
$xValue = PHPExcel_Calculation_Functions::flattenSingleValue($xValue);
if (!is_numeric($xValue)) {
return PHPExcel_Calculation_Functions::VALUE();
}
if (!self::_checkTrendArrays($yValues, $xValues)) {
return PHPExcel_Calculation_Functions::VALUE();
}
$yValueCount = count($yValues);
$xValueCount = count($xValues);
if ($yValueCount == 0 || $yValueCount != $xValueCount) {
return PHPExcel_Calculation_Functions::NA();
}
elseif ($yValueCount == 1) {
return PHPExcel_Calculation_Functions::DIV0();
}
$bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR, $yValues, $xValues);
return $bestFitLinear
->getValueOfYForX($xValue);
}