1-21. Maximum A Posteriori (MAP)

Bayesian Rule

$P(A\mid B) = \dfrac{P(A\cap B)}{P(B)} = \dfrac{P(B\mid A) P(A)}{P(B)}$

MAP

  • Measurement z 상황에 대입.

$P(x\mid z) = \dfrac{P(z\mid x)P(x)}{P(z)}$

⇒ MLE는 $P(z\mid x)$를 최대화

⇒ MAP는 $P(x\mid z)$를 최대화

  • $P(z\mid x)$는 measurement z가 이렇게 나올 조건 x를 바꿔가며 확률 밀도 값을 보자 (MLE)
  • $P(x\mid z)$는 measurement z가 이렇게 주어져 있을 때의 x에 대한 확률 밀도 값을 보자 (MAP)

$\implies \hat x = \argmax\limits_x P(x\mid z) = \argmax\limits_x \dfrac{P(z\mid x)P(x)}{P(z)}$ ⇒ $P(z)$는 무시 가능하다.

$\implies \hat x = \argmax\limits_xP(z\mid x)P(x)$

MLE vs. MAP

⇒ MLE : $\hat x = \argmax\limits_x P(z\mid x)$

⇒ MAP : $\hat x = \argmax\limits_xP(z\mid x)P(x)$

  • MAP에서의 $P(x)$는 prior distribution. 즉, 분포에 대한 사전정보이다.
  • MAP는 MLE에서의 사전 정보를 더한 것이다.
  • 하지만 Prior Distribution 자체도 추론 정보이기에 잘못된 정보라면 예측에 악영향을 미침.

MAP 적용 예시

$Let \enspace z_1 = x+n_1, \enspace z_2 = x+n_2, \enspace n \sim N(0, \sigma^2), \enspace P(x) \sim N(0, \sigma^2_x)$

$\implies P(z_1, z_2 \mid x)P(x) = P(z_1\mid x)P(z_2\mid x)P(x)$

$= \dfrac{1}{\sqrt{2\pi\sigma^2}}e^{-\dfrac{(z_1-x)^2}{2\sigma^2}}\cdot\dfrac{1}{\sqrt{2\pi\sigma^2}}e^{-\dfrac{(z_2-x)^2}{2\sigma^2}}\cdot\dfrac{1}{\sqrt{2\pi\sigma^2_x}}e^{-\dfrac{x^2}{2\sigma^2_x}}$

  • MLE와 동일하게 미분을 위해 log를 취해주고 상수를 제거한다.
  • 이후 0으로 방정식을 만들고 $\hat x$를 구한다.

$= log(e^{-\dfrac{(z_1-x)^2}{2\sigma^2}} -e^{\dfrac{(z_2-x)^2}{2\sigma^2}}-e^{\dfrac{x^2}{2\sigma_x^2}})$

$= -\dfrac{(z_1-x)^2}{2\sigma^2} -\dfrac{(z_2-x)^2}{2\sigma^2}-\dfrac{x^2}{2\sigma_x^2}$

  • 미분 취하기

$\implies \dfrac{z_1-x}{\sigma^2} + \dfrac{z_2-x}{\sigma^2} + \dfrac{x^2}{\sigma^2_x}$

$\implies \dfrac{z_1-\hat x}{\sigma^2} + \dfrac{z_2- \hat x}{\sigma^2} + \dfrac{\hat x^2}{\sigma^2_x} = 0$

$\implies \sigma^2_x(z_1-\hat x) + \sigma^2_x(z_2 - \hat x)-\sigma^2\hat x = 0$

$\implies \sigma^2_x(z_1+z_2) = \hat x(2\sigma^2_x+\sigma^2)$

$\therefore \hat x = \dfrac{\sigma_x^2(z_1+z_2)}{2\sigma_x^2 + \sigma^2} = \dfrac{z_1+z_2}{2+\dfrac{\sigma^2}{\sigma^2_x}}$

  • MLE와 동일한 항에 $\dfrac{\sigma^2}{\sigma^2_x}$만 더한 것.
  • MAP의 결과물은 L2 Regularization의 loss function과 동일하다.

Updated: