1
2
3
4
5
6
7
8
9 """Fixer for rdist in scipy
10 """
11
12 __docformat__ = 'restructuredtext'
13
14 from mvpa.base import externals
15
16 if __debug__:
17 from mvpa.base import debug
18
19 if externals.exists('scipy', raiseException=True):
20 import scipy
21 import scipy.stats
22 import scipy.stats as stats
23
24 if not externals.exists('good scipy.stats.rdist'):
25 if __debug__:
26 debug("EXT", "Fixing up scipy.stats.rdist")
27
28
29 import numpy as N
30
31 from scipy.stats.distributions import rv_continuous
32 from scipy import special
33 import scipy.integrate
34
35
36
37
39 - def _pdf(self, x, c):
40 return N.power((1.0-x*x),c/2.0-1) / special.beta(0.5,c/2.0)
42
43 return 0.5 + x/special.beta(0.5,c/2.0)* \
44 special.hyp2f1(0.5,1.0-c/2.0,1.5,x*x)
46 return (1-(n % 2))*special.beta((n+1.0)/2,c/2.0)
47
48
49
50 rdist = rdist_gen(a=-1.0, b=1.0, name="rdist", longname="An R-distributed",
51 shapes="c", extradoc="""
52
53 R-distribution
54
55 rdist.pdf(x,c) = (1-x**2)**(c/2-1) / B(1/2, c/2)
56 for -1 <= x <= 1, c > 0.
57 """
58 )
59
60 if rdist.veccdf.nin == 1:
61 if __debug__:
62 debug("EXT", "Fixing up veccdf.nin to make 2 for rdist")
63 rdist.veccdf.nin = 2
64
65 scipy.stats.distributions.rdist_gen = scipy.stats.rdist_gen = rdist_gen
66 scipy.stats.distributions.rdist = scipy.stats.rdist = rdist
67