= 1 || $r₂ >= 1) { throw new Exception\OutOfBoundsException('r must be greater than or equal to 1'); } $½ = 0.5; return \abs(($½ * \log((1 + $r₁) / (1 - $r₁))) - ($½ * \log((1 + $r₂) / (1 - $r₂)))); } /** * Cohen's d * * 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. * * @param float $μ₁ Mean of sample population 1 * @param float $μ₂ Mean of sample population 2 * @param float $s₁ Standard deviation of sample population 1 * @param float $s₂ Standard deviation of sample population 2 * * @return float */ public static function cohensD(float $μ₁, float $μ₂, float $s₁, float $s₂): float { // Variance of each data set $s₁² = $s₁ * $s₁; $s₂² = $s₂ * $s₂; // Pooled standard deviation $s = \sqrt(($s₁² + $s₂²) / 2); // d return ($μ₁ - $μ₂) / $s; } /** * Hedges' g * * The difference between two means divided by a standard deviation for the data. * https://en.wikipedia.org/wiki/Effect_size#Hedges.27_g * http://www.polyu.edu.hk/mm/effectsizefaqs/effect_size_equations2.html * * μ₁ - μ₂ * g = ------- * s* * * _________________________ * /(n₁ - 1)s₁² + (n₂ - 1)s₂² * s* = / ------------------------- * √ n₁ + n₂ - 2 * * * Then, to remove bias * * / 3 \ * g* ≈ | 1 - -------------- | g * \ 4(n₁ + n₂) - 9 / * * where * μ₁ = mean of sample population 1 * μ₂ = mean of sample population 2 * s₁² = variance of sample population 1 * s₂² = variance of sample population 1 * n₁ = sample size of sample population 1 * n₂ = sample size of sample population 2 * s* = pooled standard deviation * * @param float $μ₁ Mean of sample population 1 * @param float $μ₂ Mean of sample population 2 * @param float $s₁ Standard deviation of sample population 1 * @param float $s₂ Standard deviation of sample population 2 * @param int $n₁ Sample size of sample popluation 1 * @param int $n₂ Sample size of sample popluation 2 * * @return float */ public static function hedgesG(float $μ₁, float $μ₂, float $s₁, float $s₂, int $n₁, int $n₂): float { // Variance of each data set $s₁² = $s₁ * $s₁; $s₂² = $s₂ * $s₂; // Pooled standard deviation $⟮n₁ − 1⟯s₁² + ⟮n₂ − 1⟯s₂² = (($n₁ - 1) * $s₁²) + (($n₂ - 1) * $s₂²); $⟮n₁ + n₂ − 2⟯ = $n₁ + $n₂ - 2; $s* = \sqrt($⟮n₁ − 1⟯s₁² + ⟮n₂ − 1⟯s₂² / $⟮n₁ + n₂ − 2⟯); // g $g = ($μ₁ - $μ₂) / $s*; // Unbiased g return (1 - (3 / (4 * ($n₁ + $n₂) - 9))) * $g; } /** * Glass' Δ (glass' delta) * * An estimator of the effect size that uses only the standard deviation of * the second group. * https://en.wikipedia.org/wiki/Effect_size#Glass.27_.CE.94 * * μ₁ - μ₂ * Δ = ------- * s₂ * * where * μ₁ = mean of sample population 1 * μ₂ = mean of sample population 2 * s₂ = standard deviation of sample population 2 * * @param float $μ₁ Mean of sample population 1 * @param float $μ₂ Mean of sample population 2 * @param float $s₂ Standard deviation of sample population 2 * * @return float */ public static function glassDelta(float $μ₁, float $μ₂, float $s₂): float { return ($μ₁ - $μ₂) / $s₂; } }