@@ 1756-1774 (lines=19) @@ | ||
1753 | * @param bool A logical value specifying whether to force the intersect to equal 0. |
|
1754 | * @return array of float |
|
1755 | */ |
|
1756 | public static function GROWTH($yValues, $xValues = [], $newValues = [], $const = true) |
|
1757 | { |
|
1758 | $yValues = Functions::flattenArray($yValues); |
|
1759 | $xValues = Functions::flattenArray($xValues); |
|
1760 | $newValues = Functions::flattenArray($newValues); |
|
1761 | $const = (is_null($const)) ? true : (boolean) Functions::flattenSingleValue($const); |
|
1762 | ||
1763 | $bestFitExponential = \PhpOffice\PhpSpreadsheet\Shared\trend\trend::calculate(\PhpOffice\PhpSpreadsheet\Shared\trend\trend::TREND_EXPONENTIAL, $yValues, $xValues, $const); |
|
1764 | if (empty($newValues)) { |
|
1765 | $newValues = $bestFitExponential->getXValues(); |
|
1766 | } |
|
1767 | ||
1768 | $returnArray = []; |
|
1769 | foreach ($newValues as $xValue) { |
|
1770 | $returnArray[0][] = $bestFitExponential->getValueOfYForX($xValue); |
|
1771 | } |
|
1772 | ||
1773 | return $returnArray; |
|
1774 | } |
|
1775 | ||
1776 | /** |
|
1777 | * HARMEAN |
|
@@ 3372-3390 (lines=19) @@ | ||
3369 | * @param bool A logical value specifying whether to force the intersect to equal 0. |
|
3370 | * @return array of float |
|
3371 | */ |
|
3372 | public static function TREND($yValues, $xValues = [], $newValues = [], $const = true) |
|
3373 | { |
|
3374 | $yValues = Functions::flattenArray($yValues); |
|
3375 | $xValues = Functions::flattenArray($xValues); |
|
3376 | $newValues = Functions::flattenArray($newValues); |
|
3377 | $const = (is_null($const)) ? true : (boolean) Functions::flattenSingleValue($const); |
|
3378 | ||
3379 | $bestFitLinear = \PhpOffice\PhpSpreadsheet\Shared\trend\trend::calculate(\PhpOffice\PhpSpreadsheet\Shared\trend\trend::TREND_LINEAR, $yValues, $xValues, $const); |
|
3380 | if (empty($newValues)) { |
|
3381 | $newValues = $bestFitLinear->getXValues(); |
|
3382 | } |
|
3383 | ||
3384 | $returnArray = []; |
|
3385 | foreach ($newValues as $xValue) { |
|
3386 | $returnArray[0][] = $bestFitLinear->getValueOfYForX($xValue); |
|
3387 | } |
|
3388 | ||
3389 | return $returnArray; |
|
3390 | } |
|
3391 | ||
3392 | /** |
|
3393 | * TRIMMEAN |