• 卡方分布和伽马函数(Chi-Square Distribution)


    伽马函数

    要定义卡方分布,我们需要首先定义伽马函数:
    Γ ( p ) = ∫ 0 + ∞ x p − 1 e − x d x , p > 0 (1) \Gamma(p) = \int_{0}^{+ \infty} x^{p-1} e^{-x} dx, p >0 \tag{1} Γ(p)=0+xp1exdx,p>0(1)

    如果我们使用分部积分,
    Γ ( p ) = ∫ 0 + ∞ x p − 1 e − x d x = ∫ 0 + ∞ − x p − 1 d e − x = − x p − 1 e − x ∣ 0 + ∞ − ∫ 0 + ∞ [ − e − x ( p − 1 ) x p − 2 ] d x = ( p − 1 ) Γ ( p − 1 ) (2)

    \begin{aligned} \Gamma(p) &= \int_{0}^{+ \infty} x^{p-1} e^{-x} dx \\ & = \int_{0}^{+ \infty} -x^{p-1} d e^{-x} \\ & = -x^{p-1} e^{-x} |_{0}^{+ \infty} - \int_{0}^{+ \infty} \left [ - e^{-x} (p-1)x^{p-2} \right] dx \\ &= (p-1) \Gamma(p-1) \tag{2} \end{aligned}" role="presentation" style="position: relative;">\begin{aligned} \Gamma(p) &= \int_{0}^{+ \infty} x^{p-1} e^{-x} dx \\ & = \int_{0}^{+ \infty} -x^{p-1} d e^{-x} \\ & = -x^{p-1} e^{-x} |_{0}^{+ \infty} - \int_{0}^{+ \infty} \left [ - e^{-x} (p-1)x^{p-2} \right] dx \\ &= (p-1) \Gamma(p-1) \tag{2} \end{aligned}
    Γ(p)=0+xp1exdx=0+xp1dex=xp1ex0+0+[ex(p1)xp2]dx=(p1)Γ(p1)(2)

    通过这种方式,我们可以证明伽玛函数服从一个有趣的递归关系。
    Γ ( p ) = ( p − 1 ) Γ ( p − 1 ) = ( p − 1 ) ( p − 2 ) Γ ( p − 2 ) = ( p − 1 ) ( p − 2 ) ⋯ Γ ( 1 ) (3)

    Γ(p)=(p1)Γ(p1)=(p1)(p2)Γ(p2)=(p1)(p2)Γ(1)" role="presentation" style="position: relative;">Γ(p)=(p1)Γ(p1)=(p1)(p2)Γ(p2)=(p1)(p2)Γ(1)
    \tag{3} Γ(p)=(p1)Γ(p1)=(p1)(p2)Γ(p2)=(p1)(p2)Γ(1)(3)

    容易计算
    Γ ( 1 ) = 1 (4) \Gamma(1) = 1 \tag{4} Γ(1)=1(4)

    因此,我们可以得到
    Γ ( p ) = ( p − 1 ) ! (5) \Gamma(p) = (p-1)! \tag{5} Γ(p)=(p1)!(5)

    另外,我们可以计算
    Γ ( 1 2 ) = ∫ 0 + ∞ x − 1 2 e − x d x = 2 ∫ 0 + ∞ e − x d x 1 2 = 2 ∫ 0 + ∞ e − u 2 d u = 2 ⋅ 2 π 1 2 ⋅ 1 2 π 1 2 ∫ 0 + ∞ e − u 2 d u = 2 π ⋅ 1 2 = π (6)

    \begin{aligned} \Gamma(\frac{1}{2}) &= \int_{0}^{+ \infty} x^{-\frac{1}{2}} e^{-x} dx \\ &= 2 \int_{0}^{+ \infty} e^{-x} d x^{\frac{1}{2}} \\ & = 2 \int_{0}^{+ \infty} e^{-u^2} d u \\ & = 2 \cdot \sqrt{2 \pi \frac{1}{2}} \cdot \frac{1}{\sqrt{2 \pi \frac{1}{2}}} \int_{0}^{+ \infty} e^{-u^2} d u \\ & = 2 \sqrt \pi \cdot \frac{1}{2} \\ & = \sqrt \pi \tag{6} \end{aligned}" role="presentation" style="position: relative;">\begin{aligned} \Gamma(\frac{1}{2}) &= \int_{0}^{+ \infty} x^{-\frac{1}{2}} e^{-x} dx \\ &= 2 \int_{0}^{+ \infty} e^{-x} d x^{\frac{1}{2}} \\ & = 2 \int_{0}^{+ \infty} e^{-u^2} d u \\ & = 2 \cdot \sqrt{2 \pi \frac{1}{2}} \cdot \frac{1}{\sqrt{2 \pi \frac{1}{2}}} \int_{0}^{+ \infty} e^{-u^2} d u \\ & = 2 \sqrt \pi \cdot \frac{1}{2} \\ & = \sqrt \pi \tag{6} \end{aligned}
    Γ(21)=0+x21exdx=20+exdx21=20+eu2du=22π21 2π21 10+eu2du=2π 21=π (6)

    卡方分布

    如果 x \boldsymbol x x n n n个独立同分布(i.i.d.)的随机变量构成, x i ∼ N ( 0 , 1 ) , i = 0 , 1 , ⋯   , n x_i \sim \mathcal N(0, 1), i=0,1,\cdots, n xiN(0,1),i=0,1,,n,那么
    y = ∑ i = 1 n x i 2 ∼ χ n 2 (7) y = \sum_{i=1}^{n} x^2_i \sim \chi^2_n \tag{7} y=i=1nxi2χn2(7)

    where χ n 2 \chi^2_n χn2 denotes a χ 2 \chi^2 χ2 random variable with n n n degree of freedom. PDF:
    p ( y ) = { 1 2 n 2 Γ ( n 2 ) y n 2 − 1 exp ⁡ − ( 1 2 y )   for  y ≥ 0 0                                       for  y < 0 (8) p(y) =

    {12n2Γ(n2)yn21exp(12y)  for y00                                      for y<0" role="presentation" style="position: relative;">{12n2Γ(n2)yn21exp(12y)  for y00                                      for y<0
    \tag{8} p(y)={22nΓ(2n)1y2n1exp(21y)  for y00                                      for y<0(8)

    其中 Γ ( u ) \Gamma(u) Γ(u)是伽马函数。随机变量 y y y的均值和方差分别为:
    E [ y ] = n var [ y ] = 2 n (9)

    E[y]=nvar[y]=2n" role="presentation" style="position: relative;">E[y]=nvar[y]=2n
    \tag{9} E[y]var[y]=n=2n(9)

    补充
    如果 x i ∼ N ( 0 , σ 2 ) , i = 0 , 1 , ⋯   , n x_i \sim \mathcal N(0, \sigma^2), i=0,1,\cdots, n xiN(0,σ2),i=0,1,,n,那么
    p ( y ) = { 1 σ n 2 n 2 Γ ( n 2 ) y n 2 − 1 exp ⁡ − ( 1 2 σ 2 y )   for  y ≥ 0 0                                       for  y < 0 (10) p(y) =

    {1σn2n2Γ(n2)yn21exp(12σ2y)  for y00                                      for y<0" role="presentation" style="position: relative;">{1σn2n2Γ(n2)yn21exp(12σ2y)  for y00                                      for y<0
    \tag{10} p(y)={σn22nΓ(2n)1y2n1exp(2σ21y)  for y00                                      for y<0(10)

    这时,随机变量 y y y的均值和方差分别为:
    E [ y ] = n σ 2 var [ y ] = 2 n σ 4 (11)

    E[y]=nσ2var[y]=2nσ4" role="presentation" style="position: relative;">E[y]=nσ2var[y]=2nσ4
    \tag{11} E[y]var[y]=nσ2=2nσ4(11)

  • 相关阅读:
    高德地图旋转功能
    k8s证书过期处理
    Github每日精选(第60期):使用 HTML5 画布从 DOM 节点生成图像html-to-image
    小程序点击更多上拉显示选项
    【STM32单片机】俄罗斯方块游戏设计
    spring cloud-注册中心(Eureka)
    【环境装配】Anaconda在启动时闪现黑框,闪几次后仍能正常使用,解决黑框问题
    【虹科方案】虹科数字化仪——机械测量的最佳方案!(二)
    奥斯卡·王尔德
    c++ 获取当前时间(精确至秒、毫秒和微妙)
  • 原文地址:https://blog.csdn.net/weixin_43413559/article/details/126010570