[Biopython-dev] Chi2 test in Bio.Phylo.PAML.chi2
    Zheng Ruan 
    zruan1991 at gmail.com
       
    Sat Sep 14 16:49:33 UTC 2013
    
    
  
Hi all,
I am trying to use chi2 test within Biopython to reduce my dependency of
scipy. However, the chi2 test is very slow in some case of stat value when
degree of freedom is 1 (MK test has a df of 1). Here is a small example:
>>> from Bio.Phylo.PAML import chi2
>>> chi2.cdf_chi2(1, 1)
0.3173105078923443
>>> chi2.cdf_chi2(1, 2)
0.1572992072733692
>>> chi2.cdf_chi2(1, 3)
0.08326451704454607
>>> chi2.cdf_chi2(1, 4)
0.04550026405390195
>>> chi2.cdf_chi2(1, 5)
^CTraceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/rz/Working.Dir/GSoC/biopython/Bio/Phylo/PAML/chi2.py", line
20, in cdf_chi2
    prob = 1 - _incomplete_gamma(x, alpha)
  File "/home/rz/Working.Dir/GSoC/biopython/Bio/Phylo/PAML/chi2.py", line
116, in _incomplete_gamma
    pn[i] /= overflow
KeyboardInterrupt
>>> chi2.cdf_chi2(1, 6)
0.014305878510978087
>>> chi2.cdf_chi2(1, 7)
0.00815097160412992
>>> chi2.cdf_chi2(1, 8)
0.004677734999637195
>>> chi2.cdf_chi2(1, 9)
^CTraceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/rz/Working.Dir/GSoC/biopython/Bio/Phylo/PAML/chi2.py", line
20, in cdf_chi2
    prob = 1 - _incomplete_gamma(x, alpha)
  File "/home/rz/Working.Dir/GSoC/biopython/Bio/Phylo/PAML/chi2.py", line
112, in _incomplete_gamma
    pn[i] = pn[i+2]
KeyboardInterrupt
The behavior of chi2.cdf_chi2 is quite wiered. Could someone clarify this?
Thanks!
Best,
Zheng Ruan
    
    
More information about the Biopython-dev
mailing list