Bayesian (Recursive) Estimation

김민재·2024년 4월 29일
0

ML

목록 보기
5/17

Bayesian Estimation을 설명하기 위한 몇가지 이론들을 먼저 보자.

Hidden Markov Model (HMM)

Measurement Model

Example. Door open?

문이 하나 존재하고, 문의 상태를 XX, 센서의 관측을 ZZ라 하면

X={open , closed}Z={sensor_open , sensor_closed}X = \left \{ \text{open , closed}\right \} \qquad Z = \left \{ \text{sensor{\_}open , sensor{\_}closed}\right \}

다음처럼 나타낼 수 있다.
문은 외력이 작용하지 않는다고 하고, 센서의 성능은 다음과 같다고 하자.

p(sensor_openopen)=0.7,    p(sensor_openclosed)=0.2p(sensor_closedopen)=0.3     p(sensor_closedclosed)=0.8\begin{aligned} &p(\text{sensor{\_}open} | \text{open}) = 0.7, \;\; p(\text{sensor{\_}open} | \text{closed}) = 0.2 \\ &p(\text{sensor{\_}closed} | \text{open}) =0.3 \;\ \; p(\text{sensor{\_}closed} | \text{closed}) = 0.8 \end{aligned}

이제 처음에 문의 상태를 모르므로 uniform하게 확률을 설정하고, 우리가 구해야 하는 것은 센서가 열렸다는 관측이 주어졌을때, 실제로 문이 열렸는지를 알고 싶은것이다.

그렇다면 베이즈 룰에 의해 다음과 같은 식을 얻을 수 있다.

p(xjz)=p(zxi)p(xj)i=1np(zxi)p(xi)=η p(zxj)p(xj)p(x_j|z) = \frac{p(z|x_i)p(x_j)}{\sum_{i=1}^n p(z|x_i)p(x_i)} = \eta\ \cdot p(z|x_j)p(x_j)

위의 식에 아까의 확률을 곱하여 계산해보면 센서 관측이 열렸다고 주어졌을때, 실제로 문이 열렸을 확률 p(opensensor_open)=79p(\text{open}|\text{sensor{\_}open}) = \frac{7}{9} 임을 알 수 있다.

이를 간단하게 행렬 계산으로도 나타낼 수 있다

[0.7×0.50.3×0.50.2×0.50.8×0.5]=([0.70.20.30.8]T)[0.50.5]\begin{bmatrix} 0.7\times0.5 & 0.3\times 0.5\\ 0.2 \times0.5 &0.8\times0.5 \end{bmatrix} =\left ( \begin{bmatrix} 0.7 & 0.2\\ 0.3 & 0.8 \end{bmatrix}^T \right ) \odot \begin{bmatrix} 0.5\\0.5 \end{bmatrix}

그리고 1열의 결과를 normalize하면 된다.

여기서, 센서의 성능에 따라 결정되는 행렬을 Measurement Model 이라고 한다.


아마 이 그림이 HMM을 가장 잘 표현하는 그림일 것이다.

여기서는 중요한 2가지 가정이 존재한다.

  • 현재 상태 xtx_t는 이전상태 xt1x_{t-1}과 현재 control utu_t 에 stochastically dependent 하다.
  • 현재 관측 ztz_t는 현재 상태 xtx_t에만 stochastically dependent 하다.

HMM에는 여러가지 경우가 있는데, 먼저 위에서 예제로 보았던 Measurement model만 있는 경우를 먼저 보겠다.


HMM : only measurement model

아까의 예시에서 좀더 나아가, 이번엔 센서의 관측이 2번 들어온다고 해보자

p(opensensor_open , sensor_open)p(\text{open} | \text{sensor{\_}open , sensor{\_}open})

예를 들자면 이러한 경우이다.

여기서 HMM의 강력한 점이 등장하는데, 오직 현재 상태는 이전 상태에만 dependent하기 때문에,

p(opensensor_open , sensor_open)=p(opensensor_open)p(\text{open} | \text{sensor{\_}open , sensor{\_}open}) = p(\text{open} | \text{sensor{\_}open})

이렇게 된다는 것이다.

HMM : Measurement Model + State Transition without Contorl

HMM에 시간에 따른 State Transition (xtx_t)과 Measurement (zt)z_t) 가 있는 경우이다.

  • x1x_1에서 x2x_2로 state transition이 일어났고, 그때의 관측을 z2,z1z_2, z_1 이라 하면,
    p(x2z2,z1)=η2 p(z2x2,z1)p(x2z1)=η2 p(z2x2)1p(x2z1)2\begin{aligned} p(x_2|z_2,z_1) = &\eta_2 \ p(z_2|x_2,z_1)p(x_2|z_1)\\ = & \eta_2 \ \underbrace{p(z_2|x_2)}_1\underbrace{p(x_2|z_1)}_2 \end{aligned}

이다. 여기서 1번식은 measurement model로 아는 값이고, 2번식은 다음처럼 구할 수 있다.

p(x2z1)=x1p(x2x1,z1)p(x1z1)=x1p(x2x1)p(x1z1)\begin{aligned} p(x_2|z_1) = &\sum_{x_1} p(x_2|x_1,z_1)p(x_1|z_1)\\ = &\sum_{x_1}p(x_2|x_1)p(x_1|z_1) \end{aligned}

Bayesian Estimation

  • 시간 t에 대해, state trensition과 Measurement가 모두 존재할때, 다음처럼 recursive한 관계가 성립한다.
p(x0)=  Typically assumped uniform distributionp(x1z1)=  η1 p(z1x1)x0p(x1x0)p(x0)p(x2,z2,z1)=  η2 p(z2x2)x1p(x2x1)p(x1z1)=  p(xt,zt,zt1,,z1)=  ηt p(ztxt)xt1p(xtxt1)p(xt1zt1,zt2,,z1)\begin{aligned} p(x_0) = &\;\text{Typically assumped uniform distribution} \\ p(x_1|z_1) = &\;\eta_1 \ \cdot p(z_1|x_1)\sum_{x_0}p(x_1|x_0)p(x_0)\\ p(x_2|,z_2,z_1) = &\;\eta_2 \ \cdot p(z_2|x_2)\sum_{x_1}p(x_2|x_1)p(x_1|z_1)\\ \vdots = & \;\vdots\\ p(x_t|,z_t,z_{t-1},\cdots,z_1) = &\;\eta_t \ \cdot p(z_t|x_t)\sum_{x_{t-1}}p(x_t|x_{t-1})p(x_{t-1}|z_{t-1},z_{t-2},\cdots,z_1)\\ \end{aligned}

HMM : Transition model + State Transition model with Control

위의 recursive한 식에, uu를 conditioning random variable로 포함시키면 아래와 같은 식을 얻을 수 있다.

p(xtzt,,z1,ut,,u1)=ηtp(ztxt,ut)xt1p(xtxt1,ut)p(xt1zt1,,z1,ut1,,u1)=ηtp(ztxt)xt1p(xtxt1,ut)p(xt1zt1,,z1,ut1,,u1)\begin{aligned} p(x_t|z_t,\cdots,z_1,u_t,\cdots,u_1) &= \eta_t \cdot p(z_t|x_t,u_t)\sum_{x_{t-1}}p(x_t|x_{t-1},u_t)p(x_{t-1}|z_{t-1},\cdots,z_1,u_{t-1},\cdots,u_1)\\ & = \eta_t \cdot p(z_t|x_t)\sum_{x_{t-1}}p(x_t|x_{t-1},u_t)p(x_{t-1}|z_{t-1},\cdots,z_1,u_{t-1},\cdots,u_1) \end{aligned}

위의 식을 bel(xt)bel(x_t)를 써서 정리하게 된다면, 다음과 같다.

bel(xt)=p(xtz1,,zt,u1,,ut)=ηtp(ztxt)bel(xt)\begin{aligned} bel(x_t) & = p(x_t|z_1,\cdots,z_t,u_1,\cdots,u_t)\\ & = \eta_t \cdot p(z_t|x_t) \cdot \overline{bel}(x_t) \end{aligned}

where

bel(xt)=xt1p(xtxt1,ut)p(xt1z1,,zt1,u1,,ut1)=xt1p(xtxt1,ut)bel(xt1)\begin{aligned} \overline{bel}(x_t) & = \sum_{x_{t-1}}p(x_t|x_{t-1},u_t)p(x_{t-1}|z_1,\cdots,z{t-1},u1,\cdots,u_{t-1})\\ & = \sum_{x_{t-1}}p(x_t|x_{t-1},u_t)bel(x_{t-1}) \end{aligned}

두 식을 하나로 합치면 아래와 같이 recursive한 형태로 표현된다.

bel(xt)=ηtp(ztxt)xt1p(xtxt1,ut)bel(xt1)bel(x_t) = \eta_t \cdot p(z_t|x_t) \cdot \sum_{x_{t-1}}p(x_t|x_{t-1},u_t)bel(x_{t-1})

0개의 댓글