From 48b1ac4753e687e07eab3930afbc41c7ff91085f Mon Sep 17 00:00:00 2001 From: Daniel Svitan Date: Wed, 21 May 2025 19:49:10 +0200 Subject: [PATCH] :bulb: Adjusts for population --- analysis.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/analysis.py b/analysis.py index a6e8e99..cc008ae 100644 --- a/analysis.py +++ b/analysis.py @@ -14,6 +14,17 @@ counties = [ "KE" ] counties_c = len(counties) # how many counties +counties_population = [ + 736_385, # BA + 565_900, # TN + 565_572, # TT + 665_600, # NR + 611_124, # BB + 686_063, # ZA + 810_008, # PO + 778_799 # KE +] # source: https://sk.wikipedia.org/wiki/Zoznam_krajov_na_Slovensku +total_population = sum(counties_population) categories = [ "Problematika voľného času", @@ -96,10 +107,19 @@ for sample in data_original: for i in results: observed[i] += 1 +print("Observed before adjusting for population:") +print(observed) + +# micro-wins per capita (because wins would be a tiny number) +for i in range(len(observed)): + observed[i] = observed[i] / counties_population[i] * 1_000_000 + +print("Observed after adjusting for population:") +print(observed) + expected = np.ones_like(observed) * (sum(observed) / len(observed)) -print("Data:") -print(observed) +print("Expected after adjusting for population:") print(expected) chi2, p = stats.chisquare(f_obs=observed, f_exp=expected)