PHP Class MathPHP\Statistics\RandomVariable

- Central moment - Skewness - Kurtosis - Standard Error of the Mean (SEM) - Confidence interval In probability and statistics, a random variable is a variable whose value is subject to variations due to chance. A random variable can take on a set of possible different values (similarly to other mathematical variables), each with an associated probability, in contrast to other mathematical variables. The mathematical function describing the possible values of a random variable and their associated probabilities is known as a probability distribution. Random variables can be discrete, that is, taking any of a specified finite or countable list of values, endowed with a probability mass function, characteristic of a probability distribution; or continuous, taking any numerical value in an interval or collection of intervals, via a probability density function that is characteristic of a probability distribution; or a mixture of both types. https://en.wikipedia.org/wiki/Random_variable
Datei anzeigen Open project: markrogoyski/math-php Class Usage Examples

Public Methods

Method Description
SEK ( integer $n ) : number Standard Error of Kurtosis (SEK)
SES ( integer $n ) : number Standard Error of Skewness (SES)
centralMoment ( array $X, array $n ) : number n-th Central moment A moment of a probability distribution of a random variable about the random variable's mean.
confidenceInterval ( number , number $n, number , string $cl ) : array Confidence interval Finds CI given a sample mean, sample size, and standard deviation.
isLeptokurtic ( array $X ) : boolean Is the kurtosis postive? (Leptokurtic) Indicates a peaked distribution.
isMesokurtic ( array $X ) : boolean Is the kurtosis zero? (Mesokurtic) Indicates a normal distribution.
isPlatykurtic ( array $X ) : boolean Is the kurtosis negative? (Platykurtic) Indicates a flat distribution.
kurtosis ( array $X ) : number Excess Kurtosis A measure of the "tailedness" of the probability distribution of a real-valued random variable.
populationSkewness ( array $X ) : number Popluation skewness A measure of the asymmetry of the probability distribution of a real-valued random variable about its mean.
sampleSkewness ( array $X ) : number Sample skewness A measure of the asymmetry of the probability distribution of a real-valued random variable about its mean.
sem ( array $X ) : float SEM - Convenience method for standard error of the mean
skewness ( array $X ) : number Skewness (alternative method) This method tends to match most of the online skewness calculators and examples.
standardErrorOfTheMean ( array $X ) : float Standard error of the mean (SEM) The standard deviation of the sample-mean's estimate of a population mean.
sumOfSquares ( array $numbers ) : number Sum of squares
sumOfSquaresDeviations ( array $numbers ) : number Sum of squares deviations

Method Details

SEK() public static method

______________ (n² - 1) SEK = 2(SES) / -------------- √ (n - 3)(n + 5)
public static SEK ( integer $n ) : number
$n integer Sample size
return number

SES() public static method

_____________________ 6n(n - 1) SES = / -------------------- √ (n - 2)(n + 1)(n + 3)
public static SES ( integer $n ) : number
$n integer Sample size
return number

centralMoment() public static method

It is the expected value of a specified integer power of the deviation of the random variable from the mean. https://en.wikipedia.org/wiki/Central_moment ∑⟮xᵢ - μ⟯ⁿ μn = ---------- N
public static centralMoment ( array $X, array $n ) : number
$X array list of numbers (random variable X)
$n array n-th central moment to calculate
return number n-th central moment

confidenceInterval() public static method

Uses Z score. https://en.wikipedia.org/wiki/Confidence_interval σ ci = z* -- √n interval = (μ - ci, μ + ci) Available confidence levels: See Probability\StandardNormalTable::Z_SCORES_FOR_CONFIDENCE_INTERVALS
public static confidenceInterval ( number , number $n, number , string $cl ) : array
number sample mean
$n number sample size
number standard deviation
$cl string confidence level (Ex: 95, 99, 99.5, 99.9, etc.)
return array [ ci, lower_bound, upper_bound ]

isLeptokurtic() public static method

Is the kurtosis postive? (Leptokurtic) Indicates a peaked distribution.
public static isLeptokurtic ( array $X ) : boolean
$X array list of numbers (random variable X)
return boolean true if leptokurtic

isMesokurtic() public static method

Is the kurtosis zero? (Mesokurtic) Indicates a normal distribution.
public static isMesokurtic ( array $X ) : boolean
$X array list of numbers (random variable X)
return boolean true if mesokurtic

isPlatykurtic() public static method

Is the kurtosis negative? (Platykurtic) Indicates a flat distribution.
public static isPlatykurtic ( array $X ) : boolean
$X array list of numbers (random variable X)
return boolean true if platykurtic

kurtosis() public static method

https://en.wikipedia.org/wiki/Kurtosis μ₄ γ₂ = ---- − 3 μ₂² μ₂ is the second central moment μ₄ is the fourth central moment
public static kurtosis ( array $X ) : number
$X array list of numbers (random variable X)
return number

populationSkewness() public static method

https://en.wikipedia.org/wiki/Skewness http://brownmath.com/stat/shape.htm This method tends to match Excel's SKEW.P function. μ₃ γ₁ = ------- μ₂³′² μ₂ is the second central moment μ₃ is the third central moment
public static populationSkewness ( array $X ) : number
$X array list of numbers (random variable X)
return number

sampleSkewness() public static method

https://en.wikipedia.org/wiki/Skewness http://brownmath.com/stat/shape.htm This method tends to match Excel's SKEW function. μ₃ √(n(n - 1)) γ₁ = ------- × ----------- μ₂³′² n - 2 μ₂ is the second central moment μ₃ is the third central moment n is the sample size
public static sampleSkewness ( array $X ) : number
$X array list of numbers (random variable X)
return number

sem() public static method

SEM - Convenience method for standard error of the mean
public static sem ( array $X ) : float
$X array list of numbers (random variable X)
return float

skewness() public static method

https://en.wikipedia.org/wiki/Skewness 1 ∑⟮xᵢ - μ⟯³ γ₁ = ----- × --------- N - 1 σ³ μ is the mean σ³ is the standard deviation cubed, or, the variance raised to the 3/2 power. N is the sample size
public static skewness ( array $X ) : number
$X array list of numbers (random variable X)
return number

standardErrorOfTheMean() public static method

https://en.wikipedia.org/wiki/Standard_error s SEₓ = -- √n s = sample standard deviation n = size (number of observations) of the sample
public static standardErrorOfTheMean ( array $X ) : float
$X array list of numbers (random variable X)
return float

sumOfSquares() public static method

∑⟮xᵢ⟯²
public static sumOfSquares ( array $numbers ) : number
$numbers array
return number

sumOfSquaresDeviations() public static method

∑⟮xᵢ - μ⟯²
public static sumOfSquaresDeviations ( array $numbers ) : number
$numbers array
return number