ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
trendClass Class Reference
+ Collaboration diagram for trendClass:

Static Public Member Functions

static calculate ($trendType=self::TREND_BEST_FIT, $yValues, $xValues=array(), $const =True)

Data Fields

const TREND_LINEAR = 'Linear'
const TREND_LOGARITHMIC = 'Logarithmic'
const TREND_EXPONENTIAL = 'Exponential'
const TREND_POWER = 'Power'
const TREND_POLYNOMIAL_2 = 'Polynomial_2'
const TREND_POLYNOMIAL_3 = 'Polynomial_3'
const TREND_POLYNOMIAL_4 = 'Polynomial_4'
const TREND_POLYNOMIAL_5 = 'Polynomial_5'
const TREND_POLYNOMIAL_6 = 'Polynomial_6'
const TREND_BEST_FIT = 'Bestfit'
const TREND_BEST_FIT_NO_POLY = 'Bestfit_no_Polynomials'

Static Private Attributes

static $_trendTypes
static $_trendTypePolyOrders
static $_trendCache = array()

Detailed Description

Definition at line 10 of file trendClass.php.

Member Function Documentation

static trendClass::calculate (   $trendType = self::TREND_BEST_FIT,
  $yValues,
  $xValues = array(),
  $const = True 
)
static

Definition at line 39 of file trendClass.php.

Referenced by PHPExcel_Calculation_Statistical\CORREL(), PHPExcel_Calculation_Statistical\COVAR(), PHPExcel_Calculation_Statistical\FORECAST(), PHPExcel_Calculation_Statistical\GROWTH(), PHPExcel_Calculation_Statistical\INTERCEPT(), PHPExcel_Calculation_Statistical\LINEST(), PHPExcel_Calculation_Statistical\LOGEST(), PHPExcel_Calculation_Statistical\RSQ(), PHPExcel_Calculation_Statistical\SLOPE(), PHPExcel_Calculation_Statistical\STEYX(), and PHPExcel_Calculation_Statistical\TREND().

{
// Calculate number of points in each dataset
$nY = count($yValues);
$nX = count($xValues);
// Define X Values if necessary
if ($nX == 0) {
$xValues = range(1,$nY);
$nX = $nY;
} elseif ($nY != $nX) {
// Ensure both arrays of points are the same size
trigger_error("trend(): Number of elements in coordinate arrays do not match.", E_USER_ERROR);
}
$key = md5($trendType.$const.serialize($yValues).serialize($xValues));
// Determine which trend method has been requested
switch ($trendType) {
// Instantiate and return the class for the requested trend method
case self::TREND_LINEAR :
case self::TREND_LOGARITHMIC :
case self::TREND_EXPONENTIAL :
case self::TREND_POWER :
if (!isset(self::$_trendCache[$key])) {
$className = 'PHPExcel_'.$trendType.'_Best_Fit';
self::$_trendCache[$key] = new $className($yValues,$xValues,$const);
}
return self::$_trendCache[$key];
break;
case self::TREND_POLYNOMIAL_2 :
case self::TREND_POLYNOMIAL_3 :
case self::TREND_POLYNOMIAL_4 :
case self::TREND_POLYNOMIAL_5 :
case self::TREND_POLYNOMIAL_6 :
if (!isset(self::$_trendCache[$key])) {
$order = substr($trendType,-1);
self::$_trendCache[$key] = new PHPExcel_Polynomial_Best_Fit($order,$yValues,$xValues,$const);
}
return self::$_trendCache[$key];
break;
case self::TREND_BEST_FIT :
case self::TREND_BEST_FIT_NO_POLY :
// If the request is to determine the best fit regression, then we test each trend line in turn
// Start by generating an instance of each available trend method
foreach(self::$_trendTypes as $trendMethod) {
$className = 'PHPExcel_'.$trendMethod.'BestFit';
$bestFit[$trendMethod] = new $className($yValues,$xValues,$const);
$bestFitValue[$trendMethod] = $bestFit[$trendMethod]->getGoodnessOfFit();
}
if ($trendType != self::TREND_BEST_FIT_NO_POLY) {
foreach(self::$_trendTypePolyOrders as $trendMethod) {
$order = substr($trendMethod,-1);
$bestFit[$trendMethod] = new PHPExcel_Polynomial_Best_Fit($order,$yValues,$xValues,$const);
if ($bestFit[$trendMethod]->getError()) {
unset($bestFit[$trendMethod]);
} else {
$bestFitValue[$trendMethod] = $bestFit[$trendMethod]->getGoodnessOfFit();
}
}
}
// Determine which of our trend lines is the best fit, and then we return the instance of that trend class
arsort($bestFitValue);
$bestFitType = key($bestFitValue);
return $bestFit[$bestFitType];
break;
default :
return false;
}
} // function calculate()

+ Here is the caller graph for this function:

Field Documentation

trendClass::$_trendCache = array()
staticprivate

Definition at line 36 of file trendClass.php.

trendClass::$_trendTypePolyOrders
staticprivate
Initial value:
array( self::TREND_POLYNOMIAL_2,
self::TREND_POLYNOMIAL_3,
self::TREND_POLYNOMIAL_4,
self::TREND_POLYNOMIAL_5,
self::TREND_POLYNOMIAL_6
)

Definition at line 29 of file trendClass.php.

trendClass::$_trendTypes
staticprivate
Initial value:
array( self::TREND_LINEAR,
self::TREND_LOGARITHMIC,
self::TREND_EXPONENTIAL,
self::TREND_POWER
)

Definition at line 24 of file trendClass.php.

const trendClass::TREND_BEST_FIT = 'Bestfit'

Definition at line 21 of file trendClass.php.

const trendClass::TREND_BEST_FIT_NO_POLY = 'Bestfit_no_Polynomials'

Definition at line 22 of file trendClass.php.

const trendClass::TREND_EXPONENTIAL = 'Exponential'
const trendClass::TREND_LOGARITHMIC = 'Logarithmic'

Definition at line 13 of file trendClass.php.

const trendClass::TREND_POLYNOMIAL_2 = 'Polynomial_2'

Definition at line 16 of file trendClass.php.

const trendClass::TREND_POLYNOMIAL_3 = 'Polynomial_3'

Definition at line 17 of file trendClass.php.

const trendClass::TREND_POLYNOMIAL_4 = 'Polynomial_4'

Definition at line 18 of file trendClass.php.

const trendClass::TREND_POLYNOMIAL_5 = 'Polynomial_5'

Definition at line 19 of file trendClass.php.

const trendClass::TREND_POLYNOMIAL_6 = 'Polynomial_6'

Definition at line 20 of file trendClass.php.

const trendClass::TREND_POWER = 'Power'

Definition at line 15 of file trendClass.php.


The documentation for this class was generated from the following file: