summaryrefslogtreecommitdiff
path: root/stats/student_t_distribution.py
blob: ddea26c79d728a2c6f0e6568afc13f605523d045 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

from scipy.special import gamma
import math
import matplotlib.pyplot as plt
import numpy as np


def t_dist(t, v):
    return gamma((v+1)/2)/(math.sqrt(v*math.pi)*gamma(v/2)) * (1+t**2/v)**(-(v+1)/2)


x = np.arange(-4, 4, .1)
plt.plot(x, t_dist(x, 1), label='v=1')
plt.plot(x, t_dist(x, 2), label='v=2')
plt.plot(x, t_dist(x, 5), label='v=5')
# plt.plot(x, t_dist(x, math.inf), label='v=inf')
plt.legend()
plt.show()