Completed
Push — master ( f3bcee...f964b6 )
by Xianshun
58s
created

MeanTestingUnitTest.test_mean_normal()   A

Complexity

Conditions 2

Size

Total Lines 17

Duplication

Lines 17
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
c 1
b 0
f 0
dl 17
loc 17
rs 9.4285
1
import unittest
2
3
from numpy.random.mtrand import normal
4
5
from pysie.dsl.one_group import MeanTesting
6
from pysie.stats.distributions import MeanSamplingDistribution
7
from pysie.stats.samples import Sample, SampleDistribution
8
9
10 View Code Duplication
def test_mean_student():
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
11
    mu = 0.0
12
    sigma = 1.0
13
    sample_size = 29
14
    sample = Sample()
15
16
    for i in range(sample_size):
17
        sample.add_numeric(normal(mu, sigma))
18
19
    sampling_distribution = MeanSamplingDistribution(sample_distribution=SampleDistribution(sample))
20
    testing = MeanTesting(sampling_distribution=sampling_distribution, mean_null=0.0)
21
22
    print('one tail p-value: ' + str(testing.p_value_one_tail))
23
    print('two tail p-value: ' + str(testing.p_value_two_tail))
24
    reject_one_tail, reject_two_tail = testing.will_reject(0.01)
25
    print('will reject mean = 0 (one-tail) ? ' + str(reject_one_tail))
26
    print('will reject mean = 0 (two-tail) ? ' + str(reject_two_tail))
27
28
29
class MeanTestingUnitTest(unittest.TestCase):
30
31 View Code Duplication
    def test_mean_normal(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
32
        mu = 0.0
33
        sigma = 1.0
34
        sample_size = 31
35
        sample = Sample()
36
37
        for i in range(sample_size):
38
            sample.add_numeric(normal(mu, sigma))
39
40
        sampling_distribution = MeanSamplingDistribution(sample_distribution=SampleDistribution(sample))
41
        testing = MeanTesting(sampling_distribution=sampling_distribution, mean_null=0.0)
42
43
        print('one tail p-value: ' + str(testing.p_value_one_tail))
44
        print('two tail p-value: ' + str(testing.p_value_two_tail))
45
        reject_one_tail, reject_two_tail = testing.will_reject(0.01)
46
        print('will reject mean = 0 (one-tail) ? ' + str(reject_one_tail))
47
        print('will reject mean = 0 (two-tail) ? ' + str(reject_two_tail))
48
49
50
if __name__ == '__main__':
51
    unittest.main()
52