一些函数
-
G
a
m
m
a
Gamma
Gamma 函数
Γ ( x ) = ∫ 0 ∞ t x − 1 e − t d t \Gamma(x)=\int_{0}^{\infty} t^{x-1} e^{-t} d t Γ(x)=∫0∞tx−1e−tdt - 贝叶斯概率
π ( θ ∣ x ) = f ( x ∣ θ ) π ( θ ) ∫ Θ f ( x ∣ θ ) π ( θ ) d θ \pi(\theta \mid x)=\frac{f(x \mid \theta) \pi(\theta)}{\int_{\Theta} f(x \mid \theta) \pi(\theta) d \theta} π(θ∣x)=∫Θf(x∣θ)π(θ)dθf(x∣θ)π(θ) -
B
e
t
a
Beta
Beta 函数
B ( m , n ) = ∫ 0 1 x m − 1 ( 1 − x ) n − 1 d x \mathrm{B}(m, n)=\int_{0}^{1} x^{m-1}(1-x)^{n-1} d x B(m,n)=∫01xm−1(1−x)n−1dx -
B
e
t
a
Beta
Beta 函数和
G
a
m
m
a
Gamma
Gamma 函数的关系
B ( m , n ) = Γ ( n ) Γ ( m ) Γ ( m + n ) \mathrm{B}(m, n)=\frac{\Gamma(n) \Gamma(m)}{\Gamma(m+n)} B(m,n)=Γ(m+n)Γ(n)Γ(m)
换元 x = cos 2 θ x=\cos ^{2} \theta x=cos2θ 得
B ( m , n ) = − 2 ∫ π 2 0 ( sin 2 n − 2 θ ) ( cos 2 m − 2 θ ) ( sin θ ) ( cos θ ) d x = 2 ∫ 0 π 2 ( sin 2 n − 1 θ ) ( cos 2 m − 1 θ ) d θ (a) \mathrm{B}(m,n) = -2 \int_{\frac{\pi}{2}}^{0}\left(\sin ^{2 n-2} \theta\right)\left(\cos ^{2 m-2} \theta\right)(\sin \theta)(\cos \theta) d x=2 \int_{0}^{\frac{\pi}{2}}\left(\sin ^{2 n-1} \theta\right)\left(\cos ^{2 m-1} \theta\right) d \theta \text { (a) } B(m,n)=−2∫2π0(sin2n−2θ)(cos2m−2θ)(sinθ)(cosθ)dx=2∫02π(sin2n−1θ)(cos2m−1θ)dθ (a) 考虑Gamma函数 Γ ( n ) = ∫ 0 + ∞ e − x x n − 1 d x \Gamma(n)=\int_{0}^{+\infty} e^{-x} x^{n-1} d x Γ(n)=∫0+∞e−xxn−1dx ,换元 x = y 2 x=y^{2} x=y2,得 Γ ( n ) = 2 ∫ 0 + ∞ e − y 2 y 2 n − 1 d y \Gamma(n)=2 \int_{0}^{+\infty} e^{-y^{2}} y^{2 n-1} d y Γ(n)=2∫0+∞e−y2y2n−1dy
同样, Γ ( m ) = 2 ∫ 0 + ∞ e − z 2 y 2 z − 1 d y \Gamma(m)=2 \int_{0}^{+\infty} e^{-z^{2}} y^{2 z-1} d y Γ(m)=2∫0+∞e−z2y2z−1dy
那么, Γ ( n ) Γ ( m ) = 4 ∫ 0 + ∞ ∫ 0 + ∞ e − y 2 − z 2 y 2 n − 1 z 2 m − 1 d y d z \Gamma(n) \Gamma(m)=4 \int_{0}^{+\infty} \int_{0}^{+\infty} e^{-y^{2}-z^{2}} y^{2 n-1} z^{2 m-1} dy dz Γ(n)Γ(m)=4∫0+∞∫0+∞e−y2−z2y2n−1z2m−1dydz
令 y = x cos θ , z = x sin θ y=x \cos \theta, z=x \sin \theta y=xcosθ,z=xsinθ ,
Γ ( n ) Γ ( m ) = ∫ 0 π 2 ∫ 0 + ∞ e − x 2 x 2 m + 2 n − 1 ( sin 2 n − 1 θ ) ( cos 2 m − 1 θ ) d x d θ = [ 2 ∫ 0 + ∞ e − x 2 x 2 m + 2 n − 1 d x ] [ 2 ∫ 0 π 2 ( sin 2 n − 1 θ ) ( cos 2 m − 1 θ ) d θ ] = Γ ( m + n ) B ( m , n ) \begin{aligned}\Gamma(n) \Gamma(m)&=\int_{0}^{\frac{\pi}{2}} \int_{0}^{+\infty} e^{-x^{2}} x^{2 m+2 n-1}\left(\sin ^{2 n-1} \theta\right)\left(\cos ^{2 m-1} \theta\right) d x d \theta=\left[2 \int_{0}^{+\infty} e^{-x^{2}} x^{2 m+2 n-1} d x\right]\left[2 \int_{0}^{\frac{\pi}{2}}\left(\sin ^{2 n-1} \theta\right)\left(\cos ^{2 m-1} \theta\right) d \theta\right]\\&=\Gamma(m+n)\mathrm{B}(m,n)\end{aligned} Γ(n)Γ(m)=∫02π∫0+∞e−x2x2m+2n−1(sin2n−1θ)(cos2m−1θ)dxdθ=[2∫0+∞e−x2x2m+2n−1dx][2∫02π(sin2n−1θ)(cos2m−1θ)dθ]=Γ(m+n)B(m,n)
二项分布
二项分布 = 伯努利分布,
记为
X
∼
b
(
n
,
θ
)
X\sim b(n,\theta)
X∼b(n,θ),
n
n
n 次抛硬币中获得
k
k
k 次正面的概率为:
b
(
k
,
n
,
θ
)
=
P
(
X
=
k
)
=
C
(
n
,
k
)
×
θ
k
×
(
1
−
θ
)
n
−
k
b(k,n,\theta) = P(X=k) = C(n,k) \times \theta^k \times (1-\theta)^{n-k}
b(k,n,θ)=P(X=k)=C(n,k)×θk×(1−θ)n−k
Beta分布
是指一组定义在
(
0
,
1
)
(0,1)
(0,1)区间的连续概率分布,有两个参数
α
,
β
>
0
\alpha , \beta > 0
α,β>0,称为形状参数。Beta分布定义了二项分布的参数
θ
\theta
θ 的分布,或者说 先验分布。
B
e
t
a
(
θ
;
α
,
β
)
=
θ
α
−
1
(
1
−
θ
)
β
−
1
B
(
α
,
β
)
=
Γ
(
α
+
β
)
Γ
(
α
)
Γ
(
β
)
θ
α
−
1
(
1
−
θ
)
β
−
1
Beta(\theta; \alpha, \beta)=\frac{\theta^{\alpha-1}(1-\theta)^{\beta-1}}{\mathrm{B}(\alpha, \beta)} = \frac{\Gamma(\alpha+\beta)}{\Gamma(\alpha)\Gamma(\beta)}\ \theta^{\alpha-1}(1-\theta)^{\beta-1}
Beta(θ;α,β)=B(α,β)θα−1(1−θ)β−1=Γ(α)Γ(β)Γ(α+β) θα−1(1−θ)β−1
- Beta分布与二项分布是 共轭先验 的(Conjugate prior)。即Beta分布乘上一个二项分布的似然函数后,得到的后验分布仍然是一个Beta分布。
B e t a ( θ ; α 0 , β 0 ) × b ( h i t s , h i t s + m i s s e s , θ ) = B e t a ( θ ; α 0 + h i t s , β 0 + m i s s e s ) Beta(\theta; \alpha_0, \beta_0) \times b(hits, hits+misses,\theta) = Beta(\theta; α_0+hits,β_0+misses) Beta(θ;α0,β0)×b(hits,hits+misses,θ)=Beta(θ;α0+hits,β0+misses)
多项式分布
记为
X
~
P
N
(
n
,
p
1
,
p
2
,
…
,
p
k
)
X~PN(n,p_1,p_2, …,p_k)
X~PN(n,p1,p2,…,pk)
假设随机试验有
k
k
k 个可能的结果
A
1
,
A
2
,
.
.
.
,
A
k
A_1,A_2,..., A_k
A1,A2,...,Ak,每个结果出现的次数为随机变量
X
1
,
X
2
,
.
.
.
,
X
n
X_1,X_2,...,X_n
X1,X2,...,Xn,每个结果出现的概率为
p
1
,
p
2
,
.
.
.
,
p
k
p_1,p_2,...,p_k
p1,p2,...,pk。
n
n
n 次独立重复试验中随机事件出现的次数分别为
n
1
,
n
2
,
.
.
.
,
n
k
n_1,n_2,...,n_k
n1,n2,...,nk 的概率符合 多项式分布。
P
(
X
1
=
n
1
,
X
2
=
n
2
,
…
,
X
k
=
n
k
)
=
n
!
n
1
!
n
2
!
…
n
k
!
p
1
n
1
p
2
n
2
…
p
k
n
k
P\left(X_{1}=n_{1}, X_{2}=n_{2}, \ldots, X_{k}=n_{k}\right)=\frac{n !}{n_{1} ! n_{2} ! \ldots n_{k} !} p_{1}^{n_{1}} p_{2}^{n_{2}} \ldots p_{k}^{n_{k}}
P(X1=n1,X2=n2,…,Xk=nk)=n1!n2!…nk!n!p1n1p2n2…pknk
Dirichlet 分布
D
i
r
i
c
h
l
e
t
Dirichlet
Dirichlet 分布是多项式分布的参数的分布,与多项分布是共轭先验的。即
D
i
r
i
c
h
l
e
t
Dirichlet
Dirichlet 分布乘上一个多项分布的似然函数后,得到的后验分布仍然是一个
D
i
r
i
c
h
l
e
t
Dirichlet
Dirichlet 分布。
D
i
r
i
c
h
l
e
t
(
θ
1
,
…
,
θ
K
;
α
1
,
…
,
α
K
)
=
1
B
(
α
)
∏
i
=
1
K
θ
i
α
i
−
1
=
Γ
(
∑
i
=
1
K
α
i
)
∏
i
=
1
K
Γ
(
α
i
)
∏
i
=
1
K
θ
i
α
i
−
1
Dirichlet\left(\theta_{1}, \ldots, \theta_{K} ; \alpha_{1}, \ldots, \alpha_{K}\right)=\frac{1}{\mathrm{~B}(\bm{\alpha})} \prod_{i=1}^{K} \theta_{i}^{\alpha_{i}-1} = \frac{\Gamma(\sum_{i=1}^{K}\alpha_i)}{\prod_{i=1}^{K} \Gamma(\alpha_i)}\prod_{i=1}^{K} \theta_{i}^{\alpha_{i}-1}
Dirichlet(θ1,…,θK;α1,…,αK)= B(α)1i=1∏Kθiαi−1=∏i=1KΓ(αi)Γ(∑i=1Kαi)i=1∏Kθiαi−1