Learn R Programming

msBP (version 1.4-1)

msBP.rsample: Random numbers from a random msBP densty

Description

Random numbers generation from a random density drawn from a msBP process.

Usage

msBP.rsample(n, msBPtree)

Value

A vector containing the random sample

Arguments

n

Size of the sample to be generated

msBPtree

An object of the class msBPtree

References

Canale, A. and Dunson, D. B. (2016), "Multiscale Bernstein polynomials for densities", Statistica Sinica, 26(3), 1175-1195.

Canale, A. (2017), "msBP: An R Package to Perform Bayesian Nonparametric Inference Using Multiscale Bernstein Polynomials Mixtures". Journal of Statistical Software, 78(6), 1-19.

See Also

msBP.rtree

Examples

Run this code
rand.tree <- msBP.rtree(50,2, 4)
rand.samp <- msBP.rsample(50, rand.tree)
hist(rand.samp, prob=TRUE)
prob <- msBP.compute.prob(rand.tree)
density <- msBP.pdf(prob, 100)
points(density$dens~density$y, ty='l', col=4)

Run the code above in your browser using DataLab