dsample {dsample}R Documentation

Generating Random Samples via Wang-Lee algorithm

Description

dsample generates a sample of specified size n from the target density function (up to a normalizing constant) based on the Wang-Lee algorithm.

Usage

dsample(expr, rpmat, n = 1000, nk = 10000, wconst)

Arguments

expr

expression of a target density function

rpmat

matrix containing random points for discretization

n

non-negative integer, the desired sample size.

nk

positive integer, the number of contours. See ‘Details’.

wconst

real number between 0 and 1. See ‘Details’.

Details

X has the number of rows equals to the number of discrete base points. In each row, the first element contains the functional value of the target density and the rest elements are the coordinates at which the density is evaluated. wconst is a constant for adjusting the volume of the last contour.

Value

dsample gives the samples in data.frame with number of rows n and number of columns ncol(rpmat).

References

Wang, L. and Lee, C.H. (2014). Discretization-based direct random sample generation. Computational Statistics and Data Analysis, 71, 1001-1010. Lee, C.H. (2009). Efficient Monte Carlo Random Sample Generation through Discretization, MSc thesis, Department of Satistics, University of Manitoba, Canada

Examples

## Example on page 414 in West (1993)
expr <- expression((x1*(1-x2))^5 * (x2*(1-x1))^3 * (1-x1*(1-x2)-x2*(1-x1))^37)
sets <- list(x1=runif(1e3), x2=runif(1e3))
smp <- dsample(expr=expr, rpmat=sets, nk=1e2, n=1e3)

[Package dsample version 0.91.3.4 Index]