Class: Math_Stats
Source Location: Program_Root/class/stats.class.php
A class to calculate descriptive statistics from a data set.
Author(s):
Version:
|
|
|
Inherited Variables
|
Inherited Methods
|
Class Details
[line 118]
A class to calculate descriptive statistics from a data set. Data sets can be simple arrays of data, or a cummulative hash. The second form is useful when passing large data set, for example the data set:
$data1 = array (1,2,1,1,1,1,3,3,4.1,3,2,2,4.1,1,1,2,3,3,2,2,1,1,2,2);
can be epxressed more compactly as:
$data2 = array("1"=>9, "2"=>8, "3"=>5, "4.1"=>2);
Example of use:
include_once "Math/Stats.php";
$s = new Math_Stats();
$s->setData($data1);
// or
// $s->setData($data2, STATS_DATA_CUMMULATIVE);
$stats = $s->calcBasic();
echo "Mean: ".$stats["mean"]." StDev: ".$stats["stdev"]." \n";
// using data with nulls
// first ignoring them:
$data3 = array(1.2, "foo", 2.4, 3.1, 4.2, 3.2, null, 5.1, 6.2);
$s->setNullOption(STATS_IGNORE_NULL);
$s->setData($data3);
$stats3 = $s->calcFull();
// and then assuming nulls == 0
$s->setNullOption(STATS_USE_NULL_AS_ZERO);
$s->setData($data3);
$stats3 = $s->calcFull();
Originally this class was part of NumPHP (Numeric PHP package)
Tags:
Class Variables
Class Methods
constructor Math_Stats [line 157]
Math_Stats Math_Stats(
[optional
$nullOption = STATS_REJECT_NULL])
|
|
Constructor for the class
Tags:
Parameters:
method absDev [line 502]
Calculates the absolute deviation of the data points in the set Handles cummulative data sets correctly
Tags:
method absDevWithMean [line 520]
mixed absDevWithMean(
numeric
$mean)
|
|
Calculates the absolute deviation of the data points in the set given a fixed mean (average) value. Not used in calcBasic(), calcFull() or calc(). Handles cummulative data sets correctly
Tags:
Parameters:
method calc [line 228]
Calculates the basic or full statistics for the data set
Tags:
Parameters:
method calcBasic [line 274]
Calculates a basic set of statistics
Tags:
method calcFull [line 286]
Calculates a full set of statistics
Tags:
method coeffOfVariation [line 687]
mixed coeffOfVariation(
)
|
|
Calculates the coefficient of variation of a data set. The coefficient of variation measures the spread of a set of data as a proportion of its mean. It is often expressed as a percentage. Handles cummulative data sets correctly
Tags:
method count [line 391]
Calculates the number of data points in the set Handles cummulative data sets correctly
Tags:
method frequency [line 662]
Calculates the value frequency table of a data set. Handles cummulative data sets correctly
Tags:
method getData [line 193]
Returns the data which might have been modified according to the current null handling options.
Tags:
method kurtosis [line 560]
Calculates the kurtosis of the data distribution in the set The kurtosis measures the degrees of peakedness of a distribution. It is also callesd the "excess" or "excess coefficient", and is a normalized form of the fourth central moment of a distribution. Handles cummulative data sets correctly
Tags:
method max [line 317]
Calculates the maximum of a data set. Handles cummulative data sets correctly
Tags:
method mean [line 413]
Calculates the mean (average) of the data points in the set Handles cummulative data sets correctly
Tags:
method median [line 580]
Calculates the median of a data set. The median is the value such that half of the points are below it in a sorted data set. If the number of values is odd, it is the middle item. If the number of values is even, is the average of the two middle items. Handles cummulative data sets correctly
Tags:
method midrange [line 646]
Calculates the midrange of a data set. The midrange is the average of the minimum and maximum of the data set. Handles cummulative data sets correctly
Tags:
method min [line 299]
Calculates the minimum of a data set. Handles cummulative data sets correctly
Tags:
method mode [line 611]
Calculates the mode of a data set. The mode is the value with the highest frequency in the data set. There can be more than one mode. Handles cummulative data sets correctly
Tags:
method setData [line 170]
mixed setData(
array
$arr, [optional
$opt = STATS_DATA_SIMPLE])
|
|
Sets and verifies the data, checking for nulls and using the current null handling option
Tags:
Parameters:
method setNullOption [line 207]
mixed setNullOption(
mixed
$nullOption)
|
|
Sets the null handling option. Must be called before assigning a new data set containing null values
Tags:
method skewness [line 539]
Calculates the skewness of the data distribution in the set The skewness measures the degree of asymmetry of a distribution, and is related to the third central moment of a distribution. Handles cummulative data sets correctly
Tags:
method stDev [line 448]
Calculates the standard deviation (unbiased) of the data points in the set Handles cummulative data sets correctly
Tags:
method stDevWithMean [line 485]
mixed stDevWithMean(
numeric
$mean)
|
|
Calculates the standard deviation (unbiased) of the data points in the set given a fixed mean (average) value. Not used in calcBasic(), calcFull() or calc(). Handles cummulative data sets correctly
Tags:
Parameters:
method sum [line 336]
Calculates SUM { xi } Handles cummulative data sets correctly
Tags:
method sum2 [line 350]
Calculates SUM { (xi)^2 } Handles cummulative data sets correctly
Tags:
method sumN [line 365]
Calculates SUM { (xi)^n } Handles cummulative data sets correctly
Tags:
Parameters:
method variance [line 429]
Calculates the variance (unbiased) of the data points in the set Handles cummulative data sets correctly
Tags:
method varianceWithMean [line 467]
mixed varianceWithMean(
numeric
$mean)
|
|
Calculates the variance (unbiased) of the data points in the set given a fixed mean (average) value. Not used in calcBasic(), calcFull() or calc(). Handles cummulative data sets correctly
Tags:
Parameters:
method _validate [line 757]
Utility function to validate the data and modify it according to the current null handling option
Tags:
method __sumabsdev [line 732]
mixed __sumabsdev(
[optional
$mean = null])
|
|
Utility function to calculate: SUM { | xi - mean | }
Tags:
Parameters:
method __sumdiff [line 706]
mixed __sumdiff(
numeric
$power, [optional
$mean = null])
|
|
Utility function to calculate: SUM { (xi - mean)^n }
Tags:
Parameters:
|
|