two-types anchor in "... To Make Predictions"
[Ultimately_Untrue_Thought.git] / notes / deflation.py
index 72d0927..686ef80 100644 (file)
@@ -9,7 +9,7 @@ seed(1)
 
 def cohens_d(X, Y):
     return (
-        (mean(X) + mean(Y)) /
+        (mean(X) - mean(Y)) /
         sqrt(
             (len(X)*variance(X) + len(Y)*variance(Y)) /
             (len(X) + len(Y))
@@ -36,7 +36,7 @@ true_d = cohens_d(true_f, true_m)
 print(true_d)  # 1.0193773432617055 — d≈1.0, as expected!
 
 naïve_d = cohens_d(measured_f, measured_m)
-print(naïve_d)  # 0.8953395386313235
+print(naïve_d)  # 0.8953395386313235 — deflated!
 
 
 def performance(μ_g, σ_g, s, n):
@@ -55,7 +55,7 @@ matched_f = performance(0, 0, 1, 10000)
 matched_m = performance(0, 0, 0, 10000)
 
 population_d = cohens_d(population_f, population_m)
-print(population_d)  # 0.7287587808164793
+print(population_d)  # 0.7287587808164793 — deflated!
 
 matched_d = cohens_d(matched_f, matched_m)
-print(matched_d)  # 1.018362581243161
+print(matched_d)  # 1.018362581243161 — as you would expect