@@ 106-135 (lines=30) @@ | ||
103 | ||
104 | def test_student(self): |
|
105 | grp1_sample = Sample() |
|
106 | grp2_sample = Sample() |
|
107 | ||
108 | for i in range(20): |
|
109 | if random() <= 0.6: |
|
110 | grp1_sample.add_category("OK") |
|
111 | else: |
|
112 | grp1_sample.add_category("CANCEL") |
|
113 | ||
114 | for i in range(20): |
|
115 | if random() <= 0.61: |
|
116 | grp2_sample.add_category("OK") |
|
117 | else: |
|
118 | grp2_sample.add_category("CANCEL") |
|
119 | ||
120 | sampling_distribution = ProportionDiffSamplingDistribution(grp1_sample_distribution=SampleDistribution( |
|
121 | grp1_sample, categorical_value="OK"), |
|
122 | grp2_sample_distribution=SampleDistribution( |
|
123 | grp2_sample, categorical_value="OK")) |
|
124 | self.assertEqual(sampling_distribution.distribution_family, DistributionFamily.simulation) |
|
125 | ||
126 | testing = ProportionDiffTesting(sampling_distribution=sampling_distribution) |
|
127 | print('one tail p-value: ' + str(testing.p_value_one_tail)) |
|
128 | print('two tail p-value: ' + str(testing.p_value_two_tail)) |
|
129 | reject_one_tail, reject_two_tail = testing.will_reject(0.01) |
|
130 | print('will reject p_1 == p_2 (one-tail) ? ' + str(reject_one_tail)) |
|
131 | print('will reject p_1 == p_2 (two-tail) ? ' + str(reject_two_tail)) |
|
132 | self.assertFalse(reject_one_tail) |
|
133 | self.assertFalse(reject_two_tail) |
|
134 | ||
135 | if __name__ == '__main__': |
|
136 | unittest.main() |
|
@@ 75-104 (lines=30) @@ | ||
72 | ||
73 | def test_normal(self): |
|
74 | grp1_sample = Sample() |
|
75 | grp2_sample = Sample() |
|
76 | ||
77 | for i in range(100): |
|
78 | if random() <= 0.6: |
|
79 | grp1_sample.add_category("OK") |
|
80 | else: |
|
81 | grp1_sample.add_category("CANCEL") |
|
82 | ||
83 | for i in range(100): |
|
84 | if random() <= 0.61: |
|
85 | grp2_sample.add_category("OK") |
|
86 | else: |
|
87 | grp2_sample.add_category("CANCEL") |
|
88 | ||
89 | sampling_distribution = ProportionDiffSamplingDistribution(grp1_sample_distribution=SampleDistribution( |
|
90 | grp1_sample, categorical_value="OK"), |
|
91 | grp2_sample_distribution=SampleDistribution( |
|
92 | grp2_sample, categorical_value="OK")) |
|
93 | self.assertEqual(sampling_distribution.distribution_family, DistributionFamily.normal) |
|
94 | ||
95 | testing = ProportionDiffTesting(sampling_distribution=sampling_distribution) |
|
96 | print('one tail p-value: ' + str(testing.p_value_one_tail)) |
|
97 | print('two tail p-value: ' + str(testing.p_value_two_tail)) |
|
98 | reject_one_tail, reject_two_tail = testing.will_reject(0.01) |
|
99 | print('will reject p_1 == p_2 (one-tail) ? ' + str(reject_one_tail)) |
|
100 | print('will reject p_1 == p_2 (two-tail) ? ' + str(reject_two_tail)) |
|
101 | self.assertFalse(reject_one_tail) |
|
102 | self.assertFalse(reject_two_tail) |
|
103 | ||
104 | def test_student(self): |
|
105 | grp1_sample = Sample() |
|
106 | grp2_sample = Sample() |
|
107 |