public static function PHPExcel_Calculation_Statistical::CORREL in Loft Data Grids 6.2
Same name and namespace in other branches
- 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Statistical.php \PHPExcel_Calculation_Statistical::CORREL()
* CORREL * * Returns covariance, the average of the products of deviations for each data point pair. * *
Parameters
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 1131
Class
- PHPExcel_Calculation_Statistical
- PHPExcel_Calculation_Statistical
Code
public static function CORREL($yValues, $xValues = null) {
if (is_null($xValues) || !is_array($yValues) || !is_array($xValues)) {
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
->getCorrelation();
}