Γ=ガンマ関数、γ=不完全ガンマ関数、B=不完全ベータ関数、I=正規化不完全ベータ関数
t分布
import numpy as np from pylab import * import math vs = [1.0,2.0,5.0,100.0] colors = ['b','g','r','c'] xs = np.linspace(-5,5,100) counter = 0 for v in vs: print counter fs = [] c = colors[counter] for x in xs: fs.append(math.gamma((v+1)/2)/(math.sqrt(v*math.pi)*math.gamma(v/2))*((1+x**2/v)**(-(v+1)/2))) plot(xs,fs,color=c) counter = counter+1 stringArray = [] for v in vs: stringArray.append('v={0}'.format(v)) legend(stringArray) title('Student\'s t distribution') show()
カイ2乗分布
累積分布関数
import numpy as np from pylab import * import math ks = [1.0,2.0,3.0,4.0,5.0] colors = ['b','g','r','c','m'] xs = np.linspace(0,8,50) counter = 0 for k in ks: print counter fs = [] c = colors[counter] for x in xs: f = ((0.5)**(k/2))/(math.gamma(k/2))*x**(k/2-1)*math.e**(-x/2) fs.append(f) plot(xs,fs,color=c) counter = counter+1 stringArray = [] for k in ks: stringArray.append('k={0}'.format(k)) legend(stringArray) title('Chi-squared distribution') show()
F分布
累積分布関数
import numpy as np from pylab import * import math def beta(a,b): beta = math.gamma(a)*math.gamma(b)/math.gamma(a+b) return beta ds = [(1.0,4.0),(6.0,28.0),(28.0,6.0)] colors = ['b','g','r'] xs = np.linspace(0,4,50) counter = 0 for d in ds: print counter fs = [] c = colors[counter] for x in xs: d1 = d[0] d2 = d[1] f = 1/(beta(d1/2,d2/2))*(d1*x/(d1*x+d2))**(d1/2)*(1-(d1*x/(d1*x+d2)))**(d2/2)*(x**(-1)) fs.append(f) plot(xs,fs,color=c) counter = counter+1 stringArray = [] for d in ds: stringArray.append('(d1,d2)={0}'.format(d)) legend(stringArray) title('F distribution') show()