Inverse Transfrom Method

Acceptance-Rejection Algorithm

Untitled

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

Untitled

⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐

$Y \sim g ,\space\space U \sim unif(0,1)$