Independent Monte Carlo
타겟분포 로부터의 시뮬레이션의 랜덤 draws .
적분 범위에 걸쳐 (over) support가 펼쳐져 있는 분포로부터 무작위로 포인트를 추출해서 해당 포인트들의 적분값을 종합하여 만들어내는, 적분값에 대한 통계적 측정.
let 는 의 density, . 이때
let , . Then, sampling of is $\dfrac {\sigma^2}{n} = E { \dfrac {v(x)}{n} }. This can be written as
when \sigma^2 exists, by CLT, , for large .
수치해석은 다차원 문제에는 적용하기 어렵다. 하지만, MC integration은 차원의 의 support에 걸쳐서 에서 랜덤하게 샘플링 한 후 이 영역에 대한 그 어떤 체계적인 탐색도 시도하지 않는다. 샘플링 후에는 그냥 냅둬버림. 따라서 MC는 고차원에서도 덜 피곤함.
Inverse-cdf
는 와 같은 cdf를 가짐. 이때 는 continuous distribution function, .
이때, linear interpolation을 활용해, 계산 없이 만으로 난수 샘플링 가능.
- 의 supoprt를 span하는 grid 정의
- 각 grid point에서 계산하거나 approximate
- 가장 가까운 grid points 에 대해, 에 해당하는 영역을 이하에 따라 linearly interpotate. . 이때 .
- illustration of Rejection Sampling for a target distribution using a Rejection Sampling envelope .
Rejection Sampling
의 상수배 (proportionality constant) 만이라도 계산될 수 있다면, 정확한 타겟분포 로부터의 샘플링을 위하여 Rejection Sampling 사용 가능. 이는 더 간단한 후보 (candidate) 분포로부터 샘플링한 후 이렇게 샘플링한 것 중 일부를 확률에 기반하여 랜덤하게 쳐냄으로써 샘플링 확률을 보정하는 것.
- 는 우리가 분포의 형태를 정확히 알고 있고 계산도 쉬운 덴시티라고 정의.
- 는 envelope, 이하의 성질을 갖는다. .
방법은 이하와 같다.
- 에서 샘플링.
- 일 경우 를 기각. 기각된다면 값을 target random sample의 요소로 기록하지 않음. step 1으로.
- 일 경우 set 로 한 후 를 타겟 랜덤샘플의 요소로 넣음. step 1으로.
여기서 는 채택될 후보들의 expected 비율로 해석될 수 있다.
good RS envelope의 요건:
- 간단하게 제작되거나, 모든 값에서 타겟분포를 넘김이 간단하게 확인되어야 한다.
- 샘플링이 쉬어야 한다.
- rejected draws가 적어야 한다.
Example: Normal From Double Exponential, Sampling a Bayesian Posterior
Variants of the RS: Squeeze RS
계산해내는 게 비용이 많이 들고 RS가 매력적인 상황이면 Squeeze RS에 의해 더 빠른 연산속도를 획득할 수 있음. nonnegative squeezing function 를 정의하고 이를 사용함. 이때 가 적합한 squeezing function이기 위해선 의 모든 support에서 .
- illustration of squeezed Rs for a target distribution , using envelope and squeezing function . Keep First and Keep Later correspond to steps 3 and 4 of the algorithm, respectively.
proceeds:
- 에서 샘플링.
- if , keep .
- if not, whether if , keep .
- both are not, reject .
2번에선 , 3번에선 임에 주목. 샘플링 쉬운 에서 먼저 비교해서 우선권 시드 주고, 그 후에 로 본선 해보는거.
Example: Lower Bound for Normal Generation
Variants of the RS: Adaptive RS
적절한 envelope 를 어떻게 만들 것인가? squeezed RS를 위해, support의 connected region에 대해 continuous, differentiable, log-concave인 덴시티를 만드는 자동화된 envelope 생산 전략에 해당함. 패키지로 실행.
envelopes and squeezing function for adaptive RS. The target density is smooth, nearly bell-shaped curve.
The first method discussed in the text, using the derivative of , produces the envelope shown as upper boundary of the lighter shaded region. This correponds to Equation (6.9) and Figure 6.4. Later in the text, a derivative-free method is presented. That envelope is the upper bound of the darker shaed region and corresponds to (6.11) and Figure 6.6. The squeezing function for both approaches is given by the dotted curve.
Importance Sampling
Importance Sampling 접근법은 w.r.t. its density는 이하처럼 alternative form으로 쓰일 수 있다는 것에 기반한다. 이때 는 envelope의 importance sampling function.
- (1)은 를 측정하기 위한 MC 접근법이 이하임을 제시한다. 처럼 에서 랜덤샘플을 뽑고, 이의 (이를 활용한) estimator는 이하. 이때 는 unstandardized weights, i.e., importance ratios.
(2)는 에서 의 랜덤샘플을 뽑고 이하를 계산. 이때 는 standardized weight. 이 (2)는 의 상수배 (proportionality constant) 까지만 알 수 있더라도 적용할 수 있다는 점에서 매우 중요함. 의 상수배까지만 알 수 있는 상황은 베이지안 분석의 post에서 빈번하게 발생함. Both estimators converge by the same argument applied to the simple Monte Carlo estimator.
Proceeds:
- Sample .
- Calculate
- 지정 샘플 갯수까지 반복
then,
과도한 변동성을 회피하기 위해, 는 bounded여야 하며 또한 는 보다 heavier tail을 가져야 한다. 이것이 만족되지 않는다면 standardized importance weight는 제법 커질 수 있음.
함수 는, 가 매우매우 작을 경우에만 가 커지게 만드는 녀석으로 잘 골라야 한다. 가령 가 아주 드문 상황에서만 1을 반환하는 indicator function이라면, 우리는 로 하여금 샘플링의 편의성을 위해 해당 사건을 좀 더 빈번하게 발생시키도록 하는 녀석을 고를 수도 있을 것이다. 이를 택한다면 우리는 우리의 관심사가 아닌 사건, 가령 에 대한 적절한 샘플링 power을 어느정도 희생하게 된다. 이는 낮은 확률에 해당하는 case의 측정에 특히 잘 들어맞는 방법론이다.
자체는 unbiased지만, 이를 importance weight로 standardize 하는 과정에서 에 다소 bias가 생겨버린다.
standardized weight를 쓰는 건 와 가 서로 강하게 상관관계가 있는 상황에서 더욱 우수한 estimator를 반환한다.
standardized weight는 의 비례상수를 요구하지 않는다. (우리가 갖고 있는 덴시티가 의 얼마만큼의 상수배인지를 알지 않아도 된다)
IS 방법론의 매력은 시뮬레이션의 reusability이다. 같은 sample points들과 weight들이 다양한 다른 quantity의 MC 적분 estimates를 구하는데 사용될 수 있다. (컴퓨팅 파워가 증가한 오늘날에 와서는 유의미한 장점은 아니다.)
Example: Small Tail Probabilities
Antithetic Sampling
let . 이 둘은 identically distributed, UE, and .
이 estimator 둘을 평균한 는 각 estimator들의 샘플을 2배 한 것보다 우월함. 이기 때문에 성립한다는 것을 유의.
를 MC integral estimate로 잡는다면, 이는
이때 은 그의 arguments에 monotone이며, 는 각 의 cdf이며 . 이에 의해 이기도 하며, 이에 의해 이하도 성립.
이는 의 2번째 estimator이며, 이는 와 같은 분포를 가짐.
따라서 는 의 샘플을 2배 한 것(2n)보다 더 작은 을 가지며, 따라서 더 우월함.
Control Variates
우리는 알지 못하는 quantity 를 알고자 하며, 이에 연관된 quantity 에 대해서는 알고 있음. 후자는 수치적으로 획득 가능. 은 simulation outcom에서 독립적으로 관측된 pairs of rv.
이때 MC estimator는 이하와 같다. 간에 상호연관이 있음을 유의.
즉 우리는 여기서
| MC (ex. ) | able | able |
| itself | able |
즉 와 간의 차이를 알아내고, 이 차이를 적당히 스케일링해서 에 적용한다는 것이 기본 메커니즘.
여기서 Control Variate Estimator는 . 는 사용자에 의해 정해지는 임의의 parameter. 이에 의해
이며 이가 최소가 된 경우의 분산은 아래와 같으며, 이를 최소로 하는 는 아래와 같다.
when , .
Rao-Blackwellizaiton
rs 를 활용해 를 estimation.
각각의 라고 가정하고, 조건부 기댓값 가 수치적으로 풀릴 수 있다고 가정하자.
라는 사실을 활용하여 에 대한 다른 estimator를 구축해보자.
Rao-Blackwellized estimator . 이는 ordinary MC estimator 와 같은 mean을 갖는다.
Note that
따라서 Mean Squared Error, MSE 관점에서 는 보다 우수하다.
Sampling Importance Resampling
SIR 알고리즘은 몇 타겟분포에서 실현값을 모사적으로 시뮬레이트한다. SIR은 Importance Sampling의 개념에 기초하고 있다. IS에서 우리는 IS function 에서 샘플링하는 식으로 진행했었다. 샘플의 각 point는 샘플링 확률을 보정 (correct)하기 위해 weighted 되었었으며, 이에 의해 weighted 샘플들은 타겟분포 와 연결지어질 수 있었다. 타겟분포 를 획득하기 위해 샘플링 확률 보정 목적으로 가해지는 weight는 standardized importance weight 로 불렸으며,
이렇게 획득했던 standardized weight는 이후에 출신 density가 아닌 다른 타겟 에서 다른 샘플을 생산할 때 재사용되는 것이 가능하다.
for a collection of values, , 이때 는 Importance Sampling Function.
proceeds:
- sample candidates 타겟분포 . 가 타겟분포라고?????? 수업발언
- caculate the standardized importance weights, .
- resample from with probabilities, .
| for samples | Rejection Sampling | SIR |
|---|---|---|
| perfect | not perfect | |
| distribution of generation draw is | exactly | random degree of approxiamtion to |
| required number of draws | random | determined |
It is important to consider the relative sizes of the initial sample and the resample. In principle, we require for distributional convergence of the sample.
1만개를 생산해놓고 이 안에서 추가적으로 공정을 진행해서 목표했던 랜덤한 샘플을 뽑아내는 것이 SIR. 그러나 전 영역에서 체크하는것과 생산해놓은 1만개에 randomness를 첨가하여 만들어낸 샘플은 퍼포먼스 차이가 당연히 존재. 그러나 전 영역 대비 1만개라는 한정된 영역에서 추가공정을 진행하므로 cost down.
기존에 만들어두었던 weight를 재사용하므로 시뮬레이션을 다시 할 필요가 없음. 시간 down.
| Rejection Sampling | envelope 를 만들고 이 안에서 뽑음. 이는 continuous point. | perfect, exact |
| SIR | n개의 candidate point를 이미 선택해놓고 이 안에서 뽑음. discrete. | approximate sampling |
candidate 개, 샘플 개. 당연하지만 candidate 의 숫자가 커질수록 효율성 (approximate 성능) 은 높아짐. The maximum tolerable ratio depends on the quality of the envelope, bsed on candidate samples and their weights. 이상적으로는 이 무한해지면 SIR 조차도 exact sampling일 수 있다.
The SIR algorithm can be sensitive to the choice of .
- The support of must include the entire support of , for a reweighted sample from is to approximate a sample from .
- should have heavier tails than , or more generally should be chosen to ensure that never grows to o large.
- If is nearly zero anywhere where is positive, then a draw from this region will happen only extremely rarely, but when it does it will receive a huge weight.
- weight-degeneracy problem
Example: Slash Distribution Example: Sampling a Bayesian Posterior
Sequential Monte Carlo
When the target density becomes high dimensional, SIR is increasingly inefficient and can be difficult to implement. Specifying a very good high-dimensional envelope that closely approximates the target with sufficiently heavy tails but little waste can be challenging.
Sequential Monte Carlo methods address the problem by splitting the high-dimensional task into a sequence of simpler steps, each of which updates the previous one.
represents a discrete time stochastic process with being the observation at time .
represents the entire history of the sequence.
Suppose the density of is and we wish to estimate the expected value of \pmb X_{1:t} w.r.t. .
A direct application of the SIR approach would be to draw a sample sequences from an envelope gt and then calculate the importance weighted average of this sample of values.
This SIR approach overlooks a key aspect of the problem.
- As t increases, and the expected value of evlove.
- At time it would be better to update previous inferences than to act as if we had no previous information. Inefficient !!!
Need to develop a strategy that will simulate from previously simulated and adjust the previous importance weights in order to estimate the expected value of . Sequential Importance Sampling.
SIS for Markov Process
Simplify assumption that is a Markov process.
The target density may be expressed as
Suppose that we adopt the same Markov form for the envelope, namely
Sample from and reweight each value by .
The weight at time is .
A sample of such points and their weights can be used to approximate and calculate the expected value of .
The sequential Monte Carlo algorithm for generating one sample is
- Sample . Let . Set .
- Sample .
- Append to , obtaining .
- .
- let . is the importance weight for .
- Increment t and return to step 2.
The weighted average serves as the estimate of .
Generalized Sequential Importance Sampling
Assume that is not a Markov process.
target density and envelope may be expressed as
the importance weight at time is
and the recursive updating expression for the importance weights is