当前位置:网站首页>MCS: continuous random variable - student's t distribution

MCS: continuous random variable - student's t distribution

2022-06-23 05:22:00 Fight the tiger tonight

Student’s t

Student’s t Distribution is also a very important distribution in statistical analysis , It is often used to test the significance of the mean value of variables .Student’s t Distribution is also called t Distribution , Similar to the standard normal distribution , But the tail can extend to the left and right , Depends on the parameters k k k freedom .

t Expectation and variance of distribution :

E ( t ) = 0 E(t) = 0 E(t)=0
V ( t ) = k k − 2 , k > 2 V(t) = \frac{k}{k - 2},k > 2 V(t)=k2k,k>2

t Distribution properties :

  1. When k > 30 k > 30 k>30 when ,t The distribution approximates the standard normal distribution .
  2. t、chi-Square And the standard normal distribution :
    t = z X 2 / k t = \frac{z}{\sqrt{\mathcal X^2 / k}} t=X2/kz

Generative obedience t Random variable of distribution

  1. Generate a standard normal variable : z ∼ N ( 0 , 1 ) z \sim N(0, 1) zN(0,1)
  2. Generate a degree of freedom k Of Chi-Square Variable : X k 2 \mathcal X_k^2 Xk2
  3. t = z / X k 2 / k t = z / \sqrt{\mathcal X_k^2 / k} t=z/Xk2/k
  4. Return t.

example : Generate a degree of freedom 6 Of t Variable :

  1. z = 0.71 z = 0.71 z=0.71
  2. X 6 2 = 6.29 \mathcal X_6^2 = 6.29 X62=6.29
  3. t = 0.71 / 6.29 / 6 = 0.693 t = 0.71 / \sqrt{6.29/6} = 0.693 t=0.71/6.29/6=0.693
  4. t = 0.693 t = 0.693 t=0.693
import numpy as np
import matplotlib.pyplot as plt
def generate_t_var(k=1):
    z = np.random.normal(0, 1)
    if k < 30:
        c = (np.random.normal(0, 1, size=(k))**2).sum()
        t = z / np.sqrt(c / k)
    else:
        z_ = np.random.normal(0, 1)
        c = int(k + z_ * np.sqrt(2*k) + 0.5)
        t = z / np.sqrt(c / k)
    return t

k = 1 、 10 、 30 、 50 k = 1、10、30、50 k=1103050

 Insert picture description here

原网站

版权声明
本文为[Fight the tiger tonight]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/174/202206230317071523.html