@@ 43-70 (lines=28) @@ | ||
40 | self.assertFalse(reject_one_tail) |
|
41 | self.assertFalse(reject_two_tail) |
|
42 | ||
43 | def test_student(self): |
|
44 | grp1_mu = 0.0 |
|
45 | grp1_sigma = 1.0 |
|
46 | grp1_sample_size = 29 |
|
47 | grp1_sample = Sample() |
|
48 | ||
49 | grp2_mu = 0.09 |
|
50 | grp2_sigma = 2.0 |
|
51 | grp2_sample_size = 28 |
|
52 | grp2_sample = Sample() |
|
53 | ||
54 | for i in range(grp1_sample_size): |
|
55 | grp1_sample.add_numeric(normal(grp1_mu, grp1_sigma)) |
|
56 | ||
57 | for i in range(grp2_sample_size): |
|
58 | grp2_sample.add_numeric(normal(grp2_mu, grp2_sigma)) |
|
59 | ||
60 | sampling_distribution = MeanDiffSamplingDistribution(grp1_sample_distribution=SampleDistribution(grp1_sample), |
|
61 | grp2_sample_distribution=SampleDistribution(grp2_sample)) |
|
62 | self.assertEqual(sampling_distribution.distribution_family, DistributionFamily.student_t) |
|
63 | testing = MeanDiffTesting(sampling_distribution=sampling_distribution) |
|
64 | print('one tail p-value: ' + str(testing.p_value_one_tail)) |
|
65 | print('two tail p-value: ' + str(testing.p_value_two_tail)) |
|
66 | reject_one_tail, reject_two_tail = testing.will_reject(0.01) |
|
67 | print('will reject mean_1 == mean_2 (one-tail) ? ' + str(reject_one_tail)) |
|
68 | print('will reject mean_1 == mean_2 (two-tail) ? ' + str(reject_two_tail)) |
|
69 | self.assertFalse(reject_one_tail) |
|
70 | self.assertFalse(reject_two_tail) |
|
71 | ||
72 | ||
73 | class ProportionDiffTestingUnitTest(unittest.TestCase): |
|
@@ 14-41 (lines=28) @@ | ||
11 | ||
12 | class MeanDiffTestingUnitTest(unittest.TestCase): |
|
13 | ||
14 | def test_normal(self): |
|
15 | grp1_mu = 0.0 |
|
16 | grp1_sigma = 1.0 |
|
17 | grp1_sample_size = 31 |
|
18 | grp1_sample = Sample() |
|
19 | ||
20 | grp2_mu = 0.09 |
|
21 | grp2_sigma = 2.0 |
|
22 | grp2_sample_size = 36 |
|
23 | grp2_sample = Sample() |
|
24 | ||
25 | for i in range(grp1_sample_size): |
|
26 | grp1_sample.add_numeric(normal(grp1_mu, grp1_sigma)) |
|
27 | ||
28 | for i in range(grp2_sample_size): |
|
29 | grp2_sample.add_numeric(normal(grp2_mu, grp2_sigma)) |
|
30 | ||
31 | sampling_distribution = MeanDiffSamplingDistribution(grp1_sample_distribution=SampleDistribution(grp1_sample), |
|
32 | grp2_sample_distribution=SampleDistribution(grp2_sample)) |
|
33 | self.assertEqual(sampling_distribution.distribution_family, DistributionFamily.normal) |
|
34 | testing = MeanDiffTesting(sampling_distribution=sampling_distribution) |
|
35 | print('one tail p-value: ' + str(testing.p_value_one_tail)) |
|
36 | print('two tail p-value: ' + str(testing.p_value_two_tail)) |
|
37 | reject_one_tail, reject_two_tail = testing.will_reject(0.01) |
|
38 | print('will reject mean_1 == mean_2 (one-tail) ? ' + str(reject_one_tail)) |
|
39 | print('will reject mean_1 == mean_2 (two-tail) ? ' + str(reject_two_tail)) |
|
40 | self.assertFalse(reject_one_tail) |
|
41 | self.assertFalse(reject_two_tail) |
|
42 | ||
43 | def test_student(self): |
|
44 | grp1_mu = 0.0 |