16
Frequentist VS Bayesian Integration issue ThinkBayes Introduction of bayesian inference @˜- YP tYJanuary 14, 2014 @˜- ThinkBayes

Think bayes

Embed Size (px)

DESCRIPTION

Introduction to Bayesian inference

Citation preview

Page 1: Think bayes

Frequentist VS BayesianIntegration issue

ThinkBayesIntroduction of bayesian inference

김진섭

서울대학교 보건대학원

January 14, 2014

김진섭 ThinkBayes

Page 2: Think bayes

Frequentist VS BayesianIntegration issue

목차

1 Frequentist VS Bayesian확률을 보는 관점

Bayes’ rule

2 Integration issueWhy?Simulation

김진섭 ThinkBayes

Page 3: Think bayes

Frequentist VS BayesianIntegration issue

확률을 보는 관점Bayes’ rule

객관적 VS 주관적 확률

주사위를 던져 1이 나올 확률

1 객관적: 확률은 정확한 숫자로 존재하고 그것을 추정한다.

2 주관적: 알수 없다, 믿음을 계속 업데이트할 수 밖에..

주사위를 던져 1이 나올 확률에 대한 접근법

1 객관적: 계속 던져봐서 추정해보니 확률은 1/6인 듯 하다.

2 주관적: 1/6일 것 같은데, 계속 던져보니 1/6이 맞는 것같네..

김진섭 ThinkBayes

Page 4: Think bayes

Frequentist VS BayesianIntegration issue

확률을 보는 관점Bayes’ rule

Homo bayesianis

Figure : Fun example of bayesian

김진섭 ThinkBayes

Page 5: Think bayes

Frequentist VS BayesianIntegration issue

확률을 보는 관점Bayes’ rule

Frequentist의 논쟁법

상대방: 신약이랑 기존 약이랑 혈압강하효과가 차이가 없는 것같은데..나: 뭐? 신약이랑 기존 약이랑 차이가 0이라고?? 차이가 0이라고 치자. 그러면 어쩌구저쩌구.. 이 데이터의 상황이 나올가능성이 거의 없는데(5%미만인데)? 그니까 넌 틀렸어.

1 차이가 0이라고 말한 사람은 없다. 가상의적을 난타.

2 상대방의 주장을 최대한 좁게 해석하여 반박.

3 얍삽하다.

김진섭 ThinkBayes

Page 6: Think bayes

Frequentist VS BayesianIntegration issue

확률을 보는 관점Bayes’ rule

Bayesian의 논쟁법

상대방: 신약이랑 기존 약이랑 혈압강하효과가 차이가 없는 것같은데.. N(0, 1)분포를 따르지 않을까?나: 차이가 N(0, 1)을 따른다고 가정하자. 가정에 따르면 이데이터의 상황이 주어졌을 때, 차이의 조건부확률을계산해보니 N(5, 1.2)를 따르는데?

1 사전믿음에 대한 분포를 가정: Prior

2 데이터가 주는 정보: Likelihood

3 믿음과 데이터의 정보를 종합 : Posterior- 이걸로 해석.

김진섭 ThinkBayes

Page 7: Think bayes

Frequentist VS BayesianIntegration issue

확률을 보는 관점Bayes’ rule

Conditional probability

P(A|B) = P(A ∩ B)

P(B)

P(B|A) = P(A ∩ B)

P(A)=

P(B)× P(A|B)P(A)

P(B|A) ∝ P(B)× P(A|B)

(1)

김진섭 ThinkBayes

Page 8: Think bayes

Frequentist VS BayesianIntegration issue

확률을 보는 관점Bayes’ rule

Bayesian inference

P(θ|data) = P(θ)× P(data|θ)P(data)

P(θ|data) ∝ P(θ)× P(data|θ)Posterior ∝ Prior× Likelihood

(2)

P(data) 구해야 되는데...P(data) =

∫P(θ)× P(data|θ)dθ

김진섭 ThinkBayes

Page 9: Think bayes

Frequentist VS BayesianIntegration issue

확률을 보는 관점Bayes’ rule

Prior, likelihood, posterior

Figure : Prior, likelihood, posterior

김진섭 ThinkBayes

Page 10: Think bayes

Frequentist VS BayesianIntegration issue

Why?Simulation

1 Posterior 분포를 그려야 평균 or 95% C.I....

2 Prior와 Likelihood가 적당히 좋은 함수라면 Posterior가 잘알고 있는 분포가 될 수도..

3 대부분은 Posterior는 알고 있는 분포가 아니다...적분불가능.

김진섭 ThinkBayes

Page 11: Think bayes

Frequentist VS BayesianIntegration issue

Why?Simulation

Monte Carlo integration

1 적분을 시뮬레이션으로 해결하겠다.

2 예) N(0,1) 적분 : N(0,1)에서 sample N개 뽑아서 그것의평균, N이 커지면 원래 적분값에 가까워짐.

즉, f (x) 적분할 때 f (x)에서 샘플링 많이 해서 그것의평균으로..f (x) 샘플링 어려울 땐 비슷하게 생긴 g(x)이용 : Importancesampling

김진섭 ThinkBayes

Page 12: Think bayes

Frequentist VS BayesianIntegration issue

Why?Simulation

Monte carlo example

Figure : 원의 넓이 구하기

김진섭 ThinkBayes

Page 13: Think bayes

Frequentist VS BayesianIntegration issue

Why?Simulation

Monte carlo example(2)

Figure : Integration of f (x)

김진섭 ThinkBayes

Page 14: Think bayes

Frequentist VS BayesianIntegration issue

Why?Simulation

MCMC(Markov chain Monte Carlo)

1 Monte carlo: Random sampling- 효율이 떨어짐.

2 다변량 분석, 특히 multilevel 샘플링 어렵다.

MCMC

1 Markov chain MC : 바로 전의 샘플링한것을 이용하여sampling - 효율, hierarchial model에 적합.

2 Metropolis-Hastings 알고리즘, Gibbs sampler(거의 표준)

김진섭 ThinkBayes

Page 15: Think bayes

Frequentist VS BayesianIntegration issue

Why?Simulation

Gibbs sampler

Figure : Example of gibbs sampling: 2 variables

김진섭 ThinkBayes

Page 16: Think bayes

Frequentist VS BayesianIntegration issue

Why?Simulation

Multivariable gibbs sampler

Figure : Gibbs sampling: > 2 variables

김진섭 ThinkBayes