💡 Adjusts for population

This commit is contained in:
Daniel Svitan 2025-05-21 19:49:10 +02:00
parent c3651fb62e
commit 48b1ac4753

View File

@ -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)