Beispiel #1
0
def is_poisson(data_array):
    max_window = np.max(data_array, axis=0)
    frac = max_window / data_array.sum()
        
    pval = chisq_poisson(np.array(data_array, 'i'))[1]
    if pval <= SIGNIFICANCE: #Not poisson
        return (False, frac)
    else:
        return (True, frac)
Beispiel #2
0
 def test_example_three_chisq(self):
     '''Same as one but with non contiguous data'''
     data = [8] * 2 +  [7] * 5 + [6] * 10 + [5] * 21 + \
            [4] * 29 + [3] * 41 + [2] * 47 + [1] * 31 + [0] * 14
     
     random.shuffle(data)
     
     result = chisq_poisson(data)
     self.assertAlmostEqual(2.28, result[0], 2)
     self.assertAlmostEqual(0.94, result[1], 2)
Beispiel #3
0
 def test_example_two_chisq(self):
     '''
     Based on the example:
     http://mlsc.lboro.ac.uk/resources/statistics/gofit.pdf
     (we do not treat minimum frequencies as the authors does)
     '''
     
     data = [3] * 4 + [2] * 9 + [1] * 15 + [0] * 32
     
     result = chisq_poisson(data)
     self.assertAlmostEqual(3.46, result[0], 2)
     self.assertAlmostEqual(0.18, result[1], 2)
Beispiel #4
0
 def test_example_one_chisq(self):
     '''
     Based on the example:
     http://goo.gl/PO0U8
     (we do not treat minimum frequencies as the authors does)
     '''
     data = [8] * 2 + [7] * 5 + [6] * 10 + [5] * 21 + \
            [4] * 29 + [3] * 41 + [2] * 47 + [1] * 31 + [0] * 14
     
     result = chisq_poisson(data)
     self.assertAlmostEqual(2.28, result[0], 2)
     self.assertAlmostEqual(0.94, result[1], 2)