MathPHP\Statistics\EffectSize::cohensD PHP Method

cohensD() public static method

The difference between two means divided by a standard deviation for the data. https://en.wikipedia.org/wiki/Effect_size#Cohen.27s_d μ₁ - μ₂ d = ------- s _________ s₁² + s₂² s = / --------- √ 2 where μ₁ = mean of sample population 1 μ₂ = mean of sample population 2 s₁² = variance of sample population 1 s₂² = variance of sample population 1 s = pooled standard deviation This formula uses the common simplified version of the pooled standard deviation.
public static cohensD ( number $μ₁, number $μ₂, number $s₁, number $s₂ ) : number
$μ₁ number Mean of sample population 1
$μ₂ number Mean of sample population 2
$s₁ number Standard deviation of sample population 1
$s₂ number Standard deviation of sample population 2
return number
    public static function cohensD($μ₁, $μ₂, $s₁, $s₂)
    {
        // Variance of each data set
        $s₁² = $s₁ * $s₁;
        $s₂² = $s₂ * $s₂;
        // Pooled standard deviation
        $s = sqrt(($s₁² + $s₂²) / 2);
        // d
        return ($μ₁ - $μ₂) / $s;
    }