Inverse Transfrom Method
- If X is cont. r.v with cdf F, then $F(x) \sim U[0,1]$
- Generate u from $U[0,1]$, then $Y = F−1(u)$ is a realization from F
Acceptance-Rejection Algorithm
- by sampling candidated from an easier dist
- then correcting the sampling probability by randomly rejecting some candidates
- If we have the reslut plot like that, we may accpet the red cases
x1 <- runif(300, 0, 1); y1 <- runif(300, 0, 2.6)
selected <- y1 < dbeta(x1, 3, 6)
plot(c(0,1), c(0,3), ty="n", main="A Sample Distribution",
ylab="Density f(x)", xlab="x")
curve (dbeta(x, 3, 6), add=TRUE)
lines(c(0,0,1,1), c(0,3,3,0))
points (x1, y1, col=1+1*selected, cex=0.1)
mean(selected)
accepted.points <- x1[selected]
# proportion of sample points less than 0.5
mean(accepted.points < 0.5)
# The true distribution.
pbeta(0.5, 3, 6)
$\int^{0.5}_0 f(x)dx = 0.855$
Formally of Acceptance-Rejection Algorithm
- we know $f$, but we need to simulate from $f$.
- $g(x)$: easy to separet from distribution
- envelope: $e(.)$
- $e(.)$ is not a pdf
- is a funcion that bounds my pdf
- $e(x)=g(x)/\alpha \ge f(x)$
- exceeds $f(x)$
- $0\le \alpha \le 1$
⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐
$Y \sim g ,\space\space U \sim unif(0,1)$