@@ 1825-1843 (lines=19) @@ | ||
1822 | * |
|
1823 | * @return array of float |
|
1824 | */ |
|
1825 | public static function GROWTH($yValues, $xValues = [], $newValues = [], $const = true) |
|
1826 | { |
|
1827 | $yValues = Functions::flattenArray($yValues); |
|
1828 | $xValues = Functions::flattenArray($xValues); |
|
1829 | $newValues = Functions::flattenArray($newValues); |
|
1830 | $const = (is_null($const)) ? true : (bool) Functions::flattenSingleValue($const); |
|
1831 | ||
1832 | $bestFitExponential = \PhpOffice\PhpSpreadsheet\Shared\trend\trend::calculate(\PhpOffice\PhpSpreadsheet\Shared\trend\trend::TREND_EXPONENTIAL, $yValues, $xValues, $const); |
|
1833 | if (empty($newValues)) { |
|
1834 | $newValues = $bestFitExponential->getXValues(); |
|
1835 | } |
|
1836 | ||
1837 | $returnArray = []; |
|
1838 | foreach ($newValues as $xValue) { |
|
1839 | $returnArray[0][] = $bestFitExponential->getValueOfYForX($xValue); |
|
1840 | } |
|
1841 | ||
1842 | return $returnArray; |
|
1843 | } |
|
1844 | ||
1845 | /** |
|
1846 | * HARMEAN. |
|
@@ 3526-3544 (lines=19) @@ | ||
3523 | * |
|
3524 | * @return array of float |
|
3525 | */ |
|
3526 | public static function TREND($yValues, $xValues = [], $newValues = [], $const = true) |
|
3527 | { |
|
3528 | $yValues = Functions::flattenArray($yValues); |
|
3529 | $xValues = Functions::flattenArray($xValues); |
|
3530 | $newValues = Functions::flattenArray($newValues); |
|
3531 | $const = (is_null($const)) ? true : (bool) Functions::flattenSingleValue($const); |
|
3532 | ||
3533 | $bestFitLinear = \PhpOffice\PhpSpreadsheet\Shared\trend\trend::calculate(\PhpOffice\PhpSpreadsheet\Shared\trend\trend::TREND_LINEAR, $yValues, $xValues, $const); |
|
3534 | if (empty($newValues)) { |
|
3535 | $newValues = $bestFitLinear->getXValues(); |
|
3536 | } |
|
3537 | ||
3538 | $returnArray = []; |
|
3539 | foreach ($newValues as $xValue) { |
|
3540 | $returnArray[0][] = $bestFitLinear->getValueOfYForX($xValue); |
|
3541 | } |
|
3542 | ||
3543 | return $returnArray; |
|
3544 | } |
|
3545 | ||
3546 | /** |
|
3547 | * TRIMMEAN. |