Description Usage Arguments Details Value Examples
This function "twoDsample(f, N, lbx, ubx, lby, uby)" implements two variabel rejection sampling for rvs with bounded support and which have bounded pdf.
1 | twoDsample(f, N, lbx = -5000, ubx = 5000, lby = -5000, uby = 5000)
|
f |
the pdf that we are sampling from |
N |
the nimber of attempted samples. |
lbx |
lower bound of x support of f |
ubx |
upper bound of x support of f |
lby |
lower bound of y support of f |
uby |
upper bound of y support of f |
Additionaly, the function 'twoDsampleplot()' shows the plot of simulation joint density function.
A vector containing samples from pdf ggplot of simulation joint density function
1 2 3 4 5 6 | f <- function(x){
x1 = x[1]
x2 = x[2]
ifelse(0<x1 & x1<1 & 0<x2 & x2<1 & 0<x1+x2 & x1+x2<1, 24*x1*x2, 0)}
a <- twoDsample(f , N=1000, lbx = 0, ubx = 1, lby = 0, uby = 1)
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.