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