ベイズとは何か

数学による統一的アプローチ

Slide
Author

司馬博文

Published

4/28/2024

  • トーマス・ベイズ 1701-1706:イギリスの牧師・数学者
  • ベイズの定理:確率論において,条件付き確率の計算手段を与える定理
  • ベイズ○○:○○(分野名)におけるベイズの定理の応用
    • 例:ベイズ統計,ベイズ機械学習,ベイズ推論,……
    • 例外:ベイズ計算(ベイズの定理の通りに実際に計算をするための計算手法の総称

多くの応用を持つが,原理は同一である.

ベイズ深層学習,ベイズ最適化,……

1 Who: ベイズとは誰か?

1.1 始まりは区間推定の問題であった

ベイズが取り組んだ問題(現代語訳)1

2値の確率変数は \(Y_i\in\{0,1\}\) はある確率 \(\theta\in(0,1)\)\(1\) になるとする: \[ Y_i=\begin{cases} 1&\text{確率 }\theta\text{ で}\\ 0&\text{残りの確率} 1-\theta\text{ で} \end{cases} \] このような確率変数の独立な観測 \(y_1,\cdots,y_n\) から,ある区間 \((a,b)\subset[0,1]\)\(\theta\) が入っているという確率を計算するにはどうすれば良いか?

  • 決定的特徴:未知のパラメータ \(\theta\) に対する確率分布を考えている.
  • 与えられている観測のモデル \(p(y|\theta)\) に対して,逆の条件付き確率 \(p(\theta|y)\) を考えれば良い.
  • そのための計算公式として「ベイズの定理」を導いた (Bayes, 1763)

2 What: ベイズとは何か?

2.1 ベイズの定理

ベイズの定理2

任意の可積分関数 \(g\),確率変数 \(\Theta\sim\operatorname{P}^\Theta\),部分 \(\sigma\)-代数 \(\mathcal{G}\) について, \[ \operatorname{E}[g(\Theta)|\mathcal{G}](\omega)=\frac{\int_\mathbb{R}g(\theta)p(\omega|\theta)\operatorname{P}^{\Theta}(d\theta)}{\int_\mathbb{R}p(\omega|\theta)\operatorname{P}^\Theta(d\theta)}\;\;\text{a.s.}\,\omega \]

一般には次の形で使う: \[ p(\theta|x)=\frac{p(x|\theta)p(\theta)}{\int_\Theta p(x|\theta)p(\theta)\,d\theta} \]

確率空間を \((\Omega,\mathcal{F},\operatorname{P})\),確率変数 \(\Theta\) は可測関数 \(\Omega\to\mathcal{X}\),可積分関数は \(g\in\mathcal{L}(\mathcal{X})\) とし,定理の式は確率測度 \(\operatorname{P}\) に関して確率 \(1\) で成り立つという意味であるとした.

可測空間 \((\Omega,\mathcal{G})\) 上の測度 \(\operatorname{Q}\)\[ \operatorname{Q}(B):=\int_B g(\theta(\omega))\operatorname{P}(d\omega),\qquad B\in\mathcal{G} \] と定めると, \[ \operatorname{E}[g(\Theta)|\mathcal{G}]=\frac{d \operatorname{Q}}{d \operatorname{P}}. \] なお,この定理は暗黙に条件付き期待値 \(\operatorname{P}[B|\Theta]\) は正則で,\((\Omega,\mathcal{G})\) 上の \(\sigma\)-有限な参照測度 \(\lambda\) に対して次の密度を持つことを仮定した: \[ \operatorname{P}[B|\Theta=\theta]=\int_B p(\omega|\theta)\lambda(d\omega). \] この下では,Fubini の定理から \[ \begin{align*} \operatorname{P}[B]&=\int_\mathbb{R}\operatorname{P}[B|\Theta=\theta]\operatorname{P}^\Theta(d\theta)\\ &=\int_B\int_\mathbb{R}p(\omega|\theta)\operatorname{P}^\Theta(d\theta)\lambda(d\omega) \end{align*} \] \[ \begin{align*} \operatorname{Q}[B]&=\operatorname{E}[g(\Theta)\operatorname{E}[1_B|\sigma[\Theta]]]\\ &=\int_\mathbb{R}g(\theta)\operatorname{P}[B|\Theta=\theta]\operatorname{P}^\Theta(d\theta)\\ &=\int_B\int_\mathbb{R}g(\theta)p(\omega|\theta)\operatorname{P}^\Theta(d\theta)\lambda(d\omega). \end{align*} \] よってあとは \[ \frac{d \operatorname{Q}}{d \operatorname{P}}=\frac{d \operatorname{Q}/d\lambda}{d \operatorname{P}/d\lambda}\;\operatorname{P}\text{-a.s.} \] を示せば良い.これは (Shiryaev, 2016, p. 273) に譲る.

2.2 ベイズ推論のもう一つのピース「事前分布」

2.3 帰納的推論の確率的拡張としてのベイズ推論

2.4 生物の不確実性の下での推論のモデルとしてのベイズ推論

  • 脳の平時の活動は経験的事前分布を表現していると解釈できる (Berkes et al., 2011)

  • 脳の神経回路はベイズ推論(正確には,事後分布からのサンプリング)を行っている可能性がある (Terada and Toyoizumi, 2024)

3 How: ベイズはどう使うのか?

3.1 「ベイズ計算」という分野

\[ p(\theta|x)=\frac{p(x|\theta)p(\theta)}{\int_\Theta p(x|\theta)p(\theta)\,d\theta} \]

  • ベイズの定理で終わりじゃない.

    →「どう実際に計算するか?」(特に分母の積分が問題)

  • ベイズ統計,ベイズ機械学習…… はすべてベイズの定理を使っている.

    →効率的で汎用的な計算方法を1つ見つければ,多くの応用分野に資する.

3.2 「ベイズ計算」の問題意識

  • 受験問題で出題される積分問題は,解析的に解ける異例中の異例

  • 加えて,「解析的に解ける」もののみを扱うのでは,モデリングの幅が狭すぎる

どんな関数 \(p(x|\theta),p(\theta)\) に対しても積分 \[ \int_\Theta p(x|\theta)p(\theta)\,d\theta \] が計算できる方法が欲しい.

3.3 積分はどう計算すれば良いか?

  • 数値積分(グリッド法)

    → Riemann 積分の定義を地で行く計算法

    → 3次元以上でもう現実的には計算量が爆発する

  • モンテカルロ積分法

    → 確定的なグリッドを用いるのではなく,乱数を用いる

It is evidently impractical to carry out a several hundred-dimensional integral by the usual numerical methods, so we resort to the Monte Carlo method. (Metropolis et al., 1953, p. 1088)

4 When: ベイズはいつ使えるか?

5 Why: なぜベイズなのか?

6 参考文献

Bayes, T. (1763). An essay towards solving a problem in the doctrine of chances. By the late rev. Mr. Bayes, f. R. S. Communicated by mr. Price, in a letter to john canton, a. M. F. R. s. Philosophical Transactions, 53(1763), 370–418.
Berkes, P., Orbán, G., Lengyel, M., and Fiser, J. (2011). Spontaneous cortical activity reveals hallmarks of an optimal internal model of the environment. Science, 331(6013), 83–87.
Metropolis, N., Rosenbluth, A. W., Rosenbluth, M. N., Teller, A. H., and Teller, E. (1953). Equation of state calculations by fast computing machines. The Journal of Chemical Physics, 21(6), 1087–1092.
Shiryaev, A. N. (2016). Probability-1,Vol. 95. Springer New York.
Terada, Y., and Toyoizumi, T. (2024). Chaotic neural dynamics facilitate probabilistic computations through sampling. Proceedings of the National Academy of Sciences, 121(18), e2312992121.

Footnotes

  1. (Bayes, 1763)↩︎

  2. (Shiryaev, 2016, p. 272) (34) も参照.↩︎