@@ 257-283 (lines=27) @@ | ||
254 | + ', standard_error = ' + str(sampling_distribution.standard_error) + ')') |
|
255 | print('confidence level for 95% confidence level: ' + str(sampling_distribution.confidence_interval(0.95))) |
|
256 | ||
257 | def test_confidence_interval_with_sample_simulation(self): |
|
258 | grp1_sample = Sample() |
|
259 | grp2_sample = Sample() |
|
260 | ||
261 | for i in range(10): |
|
262 | if random() <= 0.6: |
|
263 | grp1_sample.add_category("OK") |
|
264 | else: |
|
265 | grp1_sample.add_category("CANCEL") |
|
266 | ||
267 | for i in range(9): |
|
268 | if random() <= 0.61: |
|
269 | grp2_sample.add_category("OK") |
|
270 | else: |
|
271 | grp2_sample.add_category("CANCEL") |
|
272 | ||
273 | sampling_distribution = ProportionDiffSamplingDistribution( |
|
274 | grp1_sample_distribution=SampleDistribution(grp1_sample, |
|
275 | categorical_value="OK"), |
|
276 | grp2_sample_distribution=SampleDistribution( |
|
277 | grp2_sample, |
|
278 | categorical_value="OK") |
|
279 | ) |
|
280 | self.assertEqual(sampling_distribution.distribution_family, DistributionFamily.simulation) |
|
281 | print('sampling distribution: (point_estimate = ' + str(sampling_distribution.point_estimate) |
|
282 | + ', standard_error = ' + str(sampling_distribution.standard_error) + ')') |
|
283 | print('confidence level for 95% confidence level: ' + str(sampling_distribution.confidence_interval(0.95))) |
|
284 | ||
285 | ||
286 | if __name__ == '__main__': |
|
@@ 217-240 (lines=24) @@ | ||
214 | + ', standard_error = ' + str(sampling_distribution.standard_error) + ')') |
|
215 | print('confidence level for 95% confidence level: ' + str(sampling_distribution.confidence_interval(0.95))) |
|
216 | ||
217 | def test_confidence_interval_with_sample_normal(self): |
|
218 | grp1_sample = Sample() |
|
219 | grp2_sample = Sample() |
|
220 | ||
221 | for i in range(100): |
|
222 | if random() <= 0.6: |
|
223 | grp1_sample.add_category("OK") |
|
224 | else: |
|
225 | grp1_sample.add_category("CANCEL") |
|
226 | ||
227 | for i in range(100): |
|
228 | if random() <= 0.61: |
|
229 | grp2_sample.add_category("OK") |
|
230 | else: |
|
231 | grp2_sample.add_category("CANCEL") |
|
232 | ||
233 | sampling_distribution = ProportionDiffSamplingDistribution(grp1_sample_distribution=SampleDistribution( |
|
234 | grp1_sample, categorical_value="OK"), |
|
235 | grp2_sample_distribution=SampleDistribution( |
|
236 | grp2_sample, categorical_value="OK")) |
|
237 | self.assertEqual(sampling_distribution.distribution_family, DistributionFamily.normal) |
|
238 | print('sampling distribution: (point_estimate = ' + str(sampling_distribution.point_estimate) |
|
239 | + ', standard_error = ' + str(sampling_distribution.standard_error) + ')') |
|
240 | print('confidence level for 95% confidence level: ' + str(sampling_distribution.confidence_interval(0.95))) |
|
241 | ||
242 | def test_confidence_interval_with_sample_stats_simulation(self): |
|
243 | grp1_sample_proportion = 0.6 |