MathPHP\Statistics\RandomVariable::sampleSkewness PHP Method

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
    public static function sampleSkewness(array $X)
    {
        if (empty($X)) {
            return null;
        }
        $n = count($X);
        $μ₃ = self::centralMoment($X, 3);
        $μ₂ = self::centralMoment($X, 2);
        $μ₂³′² = pow($μ₂, 3 / 2);
        $√⟮n⟮n − 1⟯⟯ = sqrt($n * ($n - 1));
        return $μ₃ / $μ₂³′² * ($√⟮n⟮n − 1⟯⟯ / ($n - 2));
    }