public static function PHPExcel_Calculation_Statistical::TREND 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::TREND()
* TREND * * Returns values along a linear trend * *
Parameters
array of mixed Data Series Y: * @param array of mixed Data Series X * @param array of mixed Values of X for which we want to find Y * @param boolean A logical value specifying whether to force the intersect to equal 0. * @return array of float
File
- vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Calculation/ Statistical.php, line 3336
Class
- PHPExcel_Calculation_Statistical
- PHPExcel_Calculation_Statistical
Code
public static function TREND($yValues, $xValues = array(), $newValues = array(), $const = True) {
$yValues = PHPExcel_Calculation_Functions::flattenArray($yValues);
$xValues = PHPExcel_Calculation_Functions::flattenArray($xValues);
$newValues = PHPExcel_Calculation_Functions::flattenArray($newValues);
$const = is_null($const) ? True : (bool) PHPExcel_Calculation_Functions::flattenSingleValue($const);
$bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR, $yValues, $xValues, $const);
if (empty($newValues)) {
$newValues = $bestFitLinear
->getXValues();
}
$returnArray = array();
foreach ($newValues as $xValue) {
$returnArray[0][] = $bestFitLinear
->getValueOfYForX($xValue);
}
return $returnArray;
}