💡 Adjusts for population
This commit is contained in:
parent
c3651fb62e
commit
48b1ac4753
24
analysis.py
24
analysis.py
@ -14,6 +14,17 @@ counties = [
|
|||||||
"KE"
|
"KE"
|
||||||
]
|
]
|
||||||
counties_c = len(counties) # how many counties
|
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 = [
|
categories = [
|
||||||
"Problematika voľného času",
|
"Problematika voľného času",
|
||||||
@ -96,10 +107,19 @@ for sample in data_original:
|
|||||||
for i in results:
|
for i in results:
|
||||||
observed[i] += 1
|
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))
|
expected = np.ones_like(observed) * (sum(observed) / len(observed))
|
||||||
|
|
||||||
print("Data:")
|
print("Expected after adjusting for population:")
|
||||||
print(observed)
|
|
||||||
print(expected)
|
print(expected)
|
||||||
|
|
||||||
chi2, p = stats.chisquare(f_obs=observed, f_exp=expected)
|
chi2, p = stats.chisquare(f_obs=observed, f_exp=expected)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user