-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhypothesis_test.py
More file actions
143 lines (104 loc) · 4.73 KB
/
Copy pathhypothesis_test.py
File metadata and controls
143 lines (104 loc) · 4.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
import os
import re
import sys
import json
import math
import pickle
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib
import matplotlib.pyplot as plt
import statsmodels.stats.weightstats as sw
import scipy.stats
def hyp_test(size1, year1, size2, year2):
print("Null Hypothesis H0: year1 == year2")
print("Alternative Hypothesis HA: year1 != year2")
alpha = 0.05/2
p_h = (year2 + year1)/(size2 + size1)
stdd = ((p_h * (1 - p_h))/size2) + ((p_h * (1 - p_h))/size1)
z_value = (year2/size2 - year1/size1) / math.sqrt(stdd)
print("z value: ", z_value)
p_value = scipy.stats.norm.sf(abs(z_value))*2
print("p value: ", p_value)
if p_value > alpha:
print("H0 is correct: year1 == year2")
else:
print("Reject H0: year1 != year2")
# data = pd.Series([year1/size1, year2/size2])
# sns.distplot(data)
# plt.title('data distribution')
# plt.show()
def run_test():
print("Female proportion does not change in 2016 and 2019 in CCS")
hyp_test(1310, 231, 1543, 313)
print("\nWhite participants proportion does not change in 2016 and 2019 in CCS")
hyp_test(1310, 462, 1543, 513)
print("\nHispano participants proportion does not change in 2016 and 2019 in CCS")
hyp_test(1310, 123, 1543, 149)
print("\nAsian participants proportion does not change in 2016 and 2019 in CCS")
hyp_test(1310, 648, 1543, 823)
print("\nBlack participants proportion does not change in 2016 and 2019 in CCS")
hyp_test(1310, 77, 1543, 58)
print('\n', '*'*70)
print('\n')
print("Female proportion does not change in 2014 and 2019 in SP")
hyp_test(390, 67, 1209, 278)
print("\nWhite participants proportion does not change in 2014 and 2019 in SP")
hyp_test(390, 145, 1209, 417)
print("\nHispano participants proportion does not change in 2014 and 2019 in SP")
hyp_test(390, 33, 1209, 119)
print("\nAsian participants proportion does not change in 2014 and 2019 in SP")
hyp_test(390, 190, 1209, 616)
print("\nBlack participants proportion does not change in 2014 and 2019 in SP")
hyp_test(390, 22, 1209, 57)
print('\n', '*'*70)
print('\n')
print("Female proportion does not change in 2016 and 2019 in EuroSP")
hyp_test(216, 31, 418, 76)
print("\nWhite participants proportion does not change in 2016 and 2019 in EuroSP")
hyp_test(216, 114, 418, 155)
print("\nHispano participants proportion does not change in 2016 and 2019 in EuroSP")
hyp_test(216, 26, 418, 66)
print("\nAsian participants proportion does not change in 2016 and 2019 in EuroSP")
hyp_test(216, 58, 418, 169)
print("\nBlack participants proportion does not change in 2016 and 2019 in EuroSP")
hyp_test(216, 18, 418, 28)
print('\n', '*'*70)
print('\nCompare two different conferences')
print('\n', '*'*70)
print('\n')
print("Female proportion does not change between EuroSP and CCS in 2019")
hyp_test(418, 76, 1543, 313)
print("\nWhite participants proportion does not change between EuroSP and CCS in 2019")
hyp_test(418, 115, 1543, 513)
print("\nHispano participants proportion does not change between EuroSP and CCS in 2019")
hyp_test(418, 66, 1543, 149)
print("\nAsian participants proportion does not change between EuroSP and CCS in 2019")
hyp_test(418, 169, 1543, 823)
print("\nBlack participants proportion does not change between EuroSP and CCS in 2019")
hyp_test(418, 28, 1543, 58)
print('\n', '*'*70)
print('\n')
print("Female proportion does not change between SP and CCS in 2019")
hyp_test(1209, 278, 1543, 313)
print("\nWhite participants proportion does not change between SP and CCS in 2019")
hyp_test(1209, 417, 1543, 513)
print("\nHispano participants proportion does not change between SP and CCS in 2019")
hyp_test(1209, 119, 1543, 149)
print("\nAsian participants proportion does not change between SP and CCS in 2019")
hyp_test(1209, 616, 1543, 823)
print("\nBlack participants proportion does not change between SP and CCS in 2019")
hyp_test(1209, 57, 1543, 58)
print('\n', '*'*70)
print('\n')
print("Female proportion does not change between SP and EuroSP in 2019")
hyp_test(1209, 278, 418, 76)
print("\nWhite participants proportion does not change between SP and EuroSP in 2019")
hyp_test(1209, 417, 418, 155)
print("\nHispano participants proportion does not change between SP and EuroSP in 2019")
hyp_test(1209, 119, 418, 66)
print("\nAsian participants proportion does not change between SP and EuroSP in 2019")
hyp_test(1209, 616, 418, 169)
print("\nBlack participants proportion does not change between SP and EuroSP in 2019")
hyp_test(1209, 57, 418, 28)