twoDsample: Conditional variable Rejection Sampling

Description Usage Arguments Value Examples

Description

This function implements conditional variabel rejection sampling for rvs with bounded support x,y and which have have bounded pdf.

Usage

1
twoDsample(f, N, lbx = -5000, ubx = 5000, lby = -5000, uby = 5000)

Arguments

f

the joint pdf that we are sampling from

N

the number of attempted samples.

lbx

lower bound of support x of f

ubx

upper bound of support x of f

lby

upper bound of support y of f

uby

upper bound of support y of f

Value

A vector containing samples from pdf

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
jointPFF <- 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)}

f <- function(x){
x1 = x[1]
x2 = x[2]
ifelse(x2>0, 1/pi/(1+x1^2) * 0.05*exp(-0.05*x2), 0)}

a <- twoDsample(f = f, N=10000)
ggplot(a, aes(x, y)) +  geom_density_2d()

pinhuang0317/4800.Final.Project-KC.P.Production- documentation built on May 28, 2019, 7:37 a.m.