Description Usage Arguments Details Value Examples
This function implements two variables rejection sampling for rvs with bounded support and which have a bounded pdf.
1 2 | twoDsample(f, N = 1000, lbx = -1000, ubx = 1000, lby = -1000,
uby = 1000)
|
f |
the pdf that we are sampling from |
N |
the number of attempted samples |
lbx |
the lower bound of support x of f |
ubx |
the upper bound of support x of f |
lby |
the lower bound of support y of f |
uby |
the upper bound of support y of f |
Here are more details about the algorithm that we are using
A vector containing samples from pdf
1 2 3 4 5 6 7 8 9 10 11 12 13 | jointPFF <- function(x){
x1 = x[1]
x2 = x[2]
ifelse(0<x1 & x1<1 & 0<x2 & x2<1 , 24*x1*x2, 0)}
w = twoDsample(f = jointPFF, N=10000,0,1,0,1)
ggplot(w, aes(x, y)) + geom_density_2d()
f <- function(x){
x1 = x[1]
x2 = x[2]
ifelse(x2>0, 1/pi/(1+x1^2) * 0.05*exp(-0.05*x2), 0)}
w=twoDsample(f = f, N=10000)
ggplot(a, aes(x, y)) + geom_density_2d()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.