sample.wl
generates a sample of specified size n
from the target density funciton (up to a normalizing constant) based on the WangLee algorithm
1 
X 
must be a 
method 
wl (WangLee), fw (FuWang) 
nc 
a positive integer, the number of contours. See ‘Details’. 
n 
a nonnegative integer, the desired sample size. 
wconst 
a real number between 0 and 1. See ‘Details’. 
X
has the number of rows equals to the number of discrete base points. In each row, the first element contians the funcitonal 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 volumn of the last contour.
sample.wl
gives the drawn sample as a data.frame
with number of rows equals the specified size n
and number of columns equals ncol(x)1
.
Chel Hee Lee chl948@mail.usask.ca, Liqun Wang liqun.wang@umanitoba.ca
Wang, L. and Lee, C.H. (2014). Discretizationbased direct random sample generation. Computational Statistics and Data Analysis, 71, 10011010.
Lee, C.H. (2009). Efficient Monte Carlo Random Sample Generation through Discretization, MSc thesis, Department of Satistics, University of Manitoba, Canada
Wang, L. and Fu, J. (2007). A practical sampling approach for a bayesian mixture model with unknown number of components. Statistical Papers, 48(4):631653.
Fu, J. C. and Wang, L. (2002). A randomdiscretization based Monte Carlo sampling method and its application. Methodology and Computing in Applied Probability, 4, 525.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16  ## The following example is taken from West (1993, page 414).
## West, M. (1993). Approximating posterior distributions by mixture.
## Journal of the Royal Statistical Society  B, 55, 409422.
x1 < runif(1e5)
x2 < runif(1e5)
val < (x1*(1x2))^5 * (x2*(1x1))^3 * (1x1*(1x2)x2*(1x1))^37
support < as.data.frame(cbind(val, x1, x2))
summary(dsample(X=support, method="wl", nc=1e4, n=1e3))
summary(dsample(X=support, method="fw", nc=1e4, n=1e3))
##
## More accurate results can be achieved by increasing the number
## of dicretization points and the number of contours.

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
All documentation is copyright its authors; we didn't write any of that.