@@ 1773-1791 (lines=19) @@ | ||
1770 | * @param boolean A logical value specifying whether to force the intersect to equal 0. |
|
1771 | * @return array of float |
|
1772 | */ |
|
1773 | public static function GROWTH($yValues, $xValues = array(), $newValues = array(), $const = true) |
|
1774 | { |
|
1775 | $yValues = Functions::flattenArray($yValues); |
|
1776 | $xValues = Functions::flattenArray($xValues); |
|
1777 | $newValues = Functions::flattenArray($newValues); |
|
1778 | $const = (is_null($const)) ? true : (boolean) Functions::flattenSingleValue($const); |
|
1779 | ||
1780 | $bestFitExponential = \PhpSpreadsheet\Shared\trend\trend::calculate(\PhpSpreadsheet\Shared\trend\trend::TREND_EXPONENTIAL, $yValues, $xValues, $const); |
|
1781 | if (empty($newValues)) { |
|
1782 | $newValues = $bestFitExponential->getXValues(); |
|
1783 | } |
|
1784 | ||
1785 | $returnArray = array(); |
|
1786 | foreach ($newValues as $xValue) { |
|
1787 | $returnArray[0][] = $bestFitExponential->getValueOfYForX($xValue); |
|
1788 | } |
|
1789 | ||
1790 | return $returnArray; |
|
1791 | } |
|
1792 | ||
1793 | ||
1794 | /** |
|
@@ 3412-3430 (lines=19) @@ | ||
3409 | * @param boolean A logical value specifying whether to force the intersect to equal 0. |
|
3410 | * @return array of float |
|
3411 | */ |
|
3412 | public static function TREND($yValues, $xValues = array(), $newValues = array(), $const = true) |
|
3413 | { |
|
3414 | $yValues = Functions::flattenArray($yValues); |
|
3415 | $xValues = Functions::flattenArray($xValues); |
|
3416 | $newValues = Functions::flattenArray($newValues); |
|
3417 | $const = (is_null($const)) ? true : (boolean) Functions::flattenSingleValue($const); |
|
3418 | ||
3419 | $bestFitLinear = \PhpSpreadsheet\Shared\trend\trend::calculate(\PhpSpreadsheet\Shared\trend\trend::TREND_LINEAR, $yValues, $xValues, $const); |
|
3420 | if (empty($newValues)) { |
|
3421 | $newValues = $bestFitLinear->getXValues(); |
|
3422 | } |
|
3423 | ||
3424 | $returnArray = array(); |
|
3425 | foreach ($newValues as $xValue) { |
|
3426 | $returnArray[0][] = $bestFitLinear->getValueOfYForX($xValue); |
|
3427 | } |
|
3428 | ||
3429 | return $returnArray; |
|
3430 | } |
|
3431 | ||
3432 | ||
3433 | /** |