Completed
Push — master ( 4ceb7d...7d08c4 )
by Xianshun
01:05
created

AnovaUnitTest.test_anova()   A

Complexity

Conditions 2

Size

Total Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
c 1
b 0
f 0
dl 0
loc 23
rs 9.0856
1
import unittest
2
3
from numpy.random.mtrand import normal
4
5
from pysie.dsl.variable_independence_testing import Anova
6
from pysie.stats.samples import Sample
7
8
9
class AnovaUnitTest(unittest.TestCase):
10
    def test_anova(self):
11
        sample = Sample()
12
13
        mu1 = 1.0
14
        sigma1 = 1.0
15
16
        mu2 = 1.1
17
        sigma2 = 1.0
18
19
        mu3 = 1.09
20
        sigma3 = 1.0
21
22
        for i in range(100):
23
            sample.add_numeric(normal(mu1, sigma1), 'group1')
24
            sample.add_numeric(normal(mu2, sigma2), 'group2')
25
            sample.add_numeric(normal(mu3, sigma3), 'group3')
26
27
        testing = Anova(sample=sample)
28
29
        print('p-value: ' + str(testing.p_value))
30
        reject = testing.will_reject(0.01)
31
        print('will reject [same mean for all groups] ? ' + str(reject))
32
        self.assertFalse(reject)
33
34
if __name__ == '__main__':
35
    unittest.main()
36