[1]
公式の解答を参照。
[2]
\(P(Y_i=1)=P(Z_i \geq 0)\)
\(\displaystyle =P\left(\frac{Z_i-\mu_i}{1} \geq -\frac{\mu_i}{1}\right)\)
\(\displaystyle =P\left(\frac{Z_i-\mu_i}{1} \geq -\mu_i\right)\)
\(\displaystyle =1-P\left(\frac{Z_i-\mu_i}{1} \leq -\mu_i\right)\)
\(Z_i \sim N(\mu_i,1)\)なので、
\(\displaystyle =1-\Phi(-\mu_i)\)
\(=\Phi(\mu_i)\)
この結果と式(1)より、
\(\Phi(\mu_i)=\Phi(\alpha+\beta x_i)\)
よって、
\(\mu_i=\alpha+ \beta x_i\)
[3]
ベイズの定理により、
\(f(\alpha,\beta|\boldsymbol{z})\propto f(\boldsymbol{z}|\alpha,\beta)f(\alpha,\beta)\)
[2]より、\(Z_i\sim N(\alpha+\beta x_i,1)\)なので、
\(\displaystyle f(z_i|\alpha,\beta)\propto \exp\left(-\frac{1}{2}(z_i-\alpha-\beta x_i)^2\right)\)
よって、
\(\displaystyle f(\boldsymbol{z}|\alpha,\beta)=\prod_{i=1}^n f(z_i|\alpha,\beta)\)
\(\displaystyle \propto \prod_{i=1}^n \exp\left(-\frac{1}{2}(z_i-\alpha-\beta x_i)^2\right)\)
\(\displaystyle \propto \exp\left(-\frac{1}{2}\sum_{i=1}^n(z_i-\alpha-\beta x_i)^2\right)\)
ここで、\(\alpha,\beta\)の事前分布は独立な\(N(0,1)\)なので、
\(\displaystyle f(\alpha,\beta)\propto \exp\left(-\frac{1}{2}\alpha^2\right)\exp\left(-\frac{1}{2}\beta^2\right)\)
以上より、
\(f(\alpha,\beta|\boldsymbol{z})\) \(\displaystyle \propto \exp\left(-\frac{1}{2}\sum_{i=1}^n(z_i-\alpha-\beta x_i)^2\right)\)\(\displaystyle \exp\left(-\frac{1}{2}\alpha^2\right)\exp\left(-\frac{1}{2}\beta^2\right)\)
\(\displaystyle \propto \exp\left[-\frac{1}{2}\left(\sum_{i=1}^n(z_i-\alpha-\beta x_i)^2 +\alpha^2+\beta^2\right)\right]\)
括弧内を計算すると、
\(\displaystyle \sum_{i=1}^n(z_i-\alpha-\beta x_i)^2 +\alpha^2+\beta^2\)
\(\displaystyle = \sum_{i=1}^n z_i^2 \)\(\displaystyle +(n+1)\alpha^2 \)\(\displaystyle+\left(\sum_{i=1}^n x_i^2 +1\right)\beta^2 \)\(\displaystyle-2\alpha\sum_{i=1}^n z_i \)\(\displaystyle+2\alpha\beta\sum_{i=1}^n x_i \)\(\displaystyle-2\beta\sum_{i=1}^n x_i z_i\)
問題文で\(\displaystyle \sum_{i=1}^n x_i=0\)なので、
\(\displaystyle = \sum_{i=1}^n z_i^2 \)\(\displaystyle +(n+1)\alpha^2 \)\(\displaystyle+\left(\sum_{i=1}^n x_i^2 +1\right)\beta^2 \)\(\displaystyle-2\alpha\sum_{i=1}^n z_i \)\(\displaystyle-2\beta\sum_{i=1}^n x_i z_i\)
平方完成して、
\(\displaystyle =(n+1)\left(\alpha -\frac{\sum_{i=1}^n z_i}{n+1}\right)^2 \)\(\displaystyle -\frac{\left(\sum_{i=1}^n z_i\right)^2}{n+1} \)\(\displaystyle +\left(\sum_{i=1}^n x_i^2 +1 \right)\left(\beta – \frac{\sum_{i=1}^n x_i z_i}{\sum_{i=1}^n x_i^2 +1}\right)^2 \)\(\displaystyle -\frac{\left(\sum_{i=1}^n x_i z_i\right)^2}{\sum_{i=1}^n x_i^2 +1} \)\(\displaystyle +\sum_{i=1}^n z_i^2\)
\(\displaystyle =\frac{\left(\alpha -\frac{\sum_{i=1}^n z_i}{n+1}\right)^2}{\frac{1}{n+1}} \)\(\displaystyle -\frac{\left(\sum_{i=1}^n z_i\right)^2}{n+1} \)\(\displaystyle +\frac{\left(\beta – \frac{\sum_{i=1}^n x_i z_i}{\sum_{i=1}^n x_i^2 +1}\right)^2}{\frac{1}{\sum_{i=1}^n x_i^2 +1 }} \)\(\displaystyle -\frac{\left(\sum_{i=1}^n x_i z_i\right)^2}{\sum_{i=1}^n x_i^2 +1} \)\(\displaystyle +\sum_{i=1}^n z_i^2\)
この式で\(\alpha,\beta\)を含まない項は無視して、計算すると、
\(f(\alpha,\beta|\boldsymbol{z})\)\(\displaystyle \propto \exp\left[-\frac{1}{2}\left(\sum_{i=1}^n(z_i-\alpha-\beta x_i)^2 +\alpha^2+\beta^2\right)\right]\)
\(\displaystyle \propto \exp \left[ -\frac{1}{2}\left(\frac{\left(\alpha -\frac{\sum_{i=1}^n z_i}{n+1}\right)^2}{\frac{1}{n+1}}\right.\right.\)\(\displaystyle \left.\left.+\frac{\left(\beta – \frac{\sum_{i=1}^n x_i z_i}{\sum_{i=1}^n x_i^2 +1}\right)^2}{\frac{1}{\sum_{i=1}^n x_i^2 +1 }}\right) \right]\)
\(\displaystyle \propto \exp \left[ -\frac{1}{2}\frac{\left(\alpha -\frac{\sum_{i=1}^n z_i}{n+1}\right)^2}{\frac{1}{n+1}} \right]\)\(\displaystyle \cdot \exp \left[ -\frac{1}{2}\frac{\left(\beta – \frac{\sum_{i=1}^n x_i z_i}{\sum_{i=1}^n x_i^2 +1}\right)^2}{\frac{1}{\sum_{i=1}^n x_i^2 +1 }} \right]\)
よって、\(\alpha,\beta\)は独立で、\(\alpha \sim \displaystyle N\left (\frac{\sum_{i=1}^n z_i}{n+1},\frac{1}{n+1}\right), \)\( \displaystyle \beta \sim N\left(\frac{\sum_{i=1}^n x_i z_i}{\sum_{i=1}^n x_i^2 +1},\frac{1}{\sum_{i=1}^n x_i^2 +1} \right)\)に従う。
[4]
- \(N(0,1)\)に従う\(\alpha,\beta\)のサンプルを生成
- \(N(\alpha+\beta x_i,1)\)に従う\(Z_i\)のサンプルを生成
- \(Z_i\)と\(0\)との大小を比較して\(Y_i\)のサンプルを生成
これを行うことで計測を行わずともサンプルデータ\((x_i,y_i)\)を得ることが出来る(Gibbsサンプリング)。
また得られたデータをもとに\(L(\alpha,\beta)\)を最大化する\((\alpha,\beta)\)を計算すれば、\(\alpha,\beta\)の事後分布に従う乱数を生成出来る。
コメント