Ejemplo n.º 1
0
 /**
  *	TREND
  *
  *	Returns values along a linear trend
  *
  *	@param	array of mixed		Data Series Y
  *	@param	array of mixed		Data Series X
  *	@param	array of mixed		Values of X for which we want to find Y
  *	@param	boolean				A logical value specifying whether to force the intersect to equal 0.
  *	@return	array of float
  */
 public static function TREND($yValues, $xValues = array(), $newValues = array(), $const = True)
 {
     $yValues = PHPExcel_Calculation_Functions::flattenArray($yValues);
     $xValues = PHPExcel_Calculation_Functions::flattenArray($xValues);
     $newValues = PHPExcel_Calculation_Functions::flattenArray($newValues);
     $const = is_null($const) ? True : (bool) PHPExcel_Calculation_Functions::flattenSingleValue($const);
     $bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR, $yValues, $xValues, $const);
     if (count($newValues) == 0) {
         $newValues = $bestFitLinear->getXValues();
     }
     $returnArray = array();
     foreach ($newValues as $xValue) {
         $returnArray[0][] = $bestFitLinear->getValueOfYForX($xValue);
     }
     return $returnArray;
 }
Ejemplo n.º 2
0
 /**
  *	GROWTH
  *
  *	Returns values along a predicted emponential trend
  *
  *	@param	array of mixed		Data Series Y
  *	@param	array of mixed		Data Series X
  *	@param	array of mixed		Values of X for which we want to find Y
  *	@param	boolean				A logical value specifying whether to force the intersect to equal 0.
  *	@return	array of float
  */
 public static function GROWTH($yValues, $xValues = array(), $newValues = array(), $const = True)
 {
     $yValues = self::flattenArray($yValues);
     $xValues = self::flattenArray($xValues);
     $newValues = self::flattenArray($newValues);
     $const = (bool) self::flattenSingleValue($const);
     $bestFitExponential = trendClass::calculate(trendClass::TREND_EXPONENTIAL, $yValues, $xValues, $const);
     if (count($newValues) == 0) {
         $newValues = $bestFitExponential->getXValues();
     }
     $returnArray = array();
     foreach ($newValues as $xValue) {
         $returnArray[0][] = $bestFitExponential->getValueOfYForX($xValue);
     }
     return $returnArray;
 }