Exercise 4.1 Solution Example - Hoff, A First Course in Bayesian Statistical Methods
標準ベイズ統計学 演習問題 4.1 解答例

Table of Contents

answer

\(\theta_1, \theta_2\)それぞれの事後分布は、 (θ_1, θ_2\) are given by

\begin{align*} & \theta_1 \sim \text{Beta}(1 +57, 1 + 43) \\ & \theta_2 \sim \text{Beta}(1 + 30, 1 + 20) \\ \end{align*}

である。 Pr(\(\theta_1 < \theta_2 \mid\) the data and prior) は、以下のように計算できる。 (can be calculated as follows.)

using Distributions
using Random
Random.seed!(1234)
a, b = 1, 1
sy₁, n₁ = 57, 100
sy₂, n₂ = 30, 50

θ₁_mc = rand(Beta(a + sy₁, b + n₁ -sy₁), 5000)
θ₂_mc = rand(Beta(a + sy₂, b + n₂ -sy₂), 5000)

mean(θ₁_mc .< θ₂_mc)
0.626

よって、事後分布の比較により、\(\theta_2\)の方が大きい事後確率は約 63%である。 (The posterior probability that \(\theta_2\) is larger than \(\theta_1\) is about 63%.)

Author: Kaoru Babasaki

Email: [email protected]

Last Updated: 2025-05-02 金 16:29

home Home | ホーム | GitHub