Description Usage Arguments Details Value Author(s) References Examples

`sample.wl`

generates a sample of specified size `n`

from the target density funciton (up to a normalizing constant) based on the Wang-Lee algorithm

1 |

`X` |
must be a |

`method` |
wl (Wang-Lee), fw (Fu-Wang) |

`nc` |
a positive integer, the number of contours. See ‘Details’. |

`n` |
a non-negative 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 [email protected], Liqun Wang [email protected]

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

Wang, L. and Fu, J. (2007). A practical sampling approach for a bayesian mixture model with unknown number of components. Statistical Papers, 48(4):631-653.

Fu, J. C. and Wang, L. (2002). A random-discretization based Monte Carlo sampling method and its application. Methodology and Computing in Applied Probability, 4, 5-25.

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, 409-422.
x1 <- runif(1e5)
x2 <- runif(1e5)
val <- (x1*(1-x2))^5 * (x2*(1-x1))^3 * (1-x1*(1-x2)-x2*(1-x1))^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.
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.