LHSpmf | R Documentation |
Sample from a probability mass function (PMF) via Latin hypercube sampling.
LHSpmf(pmf, sampleSize, seed)
pmf |
A 2-column data frame as a PMF. The 1st column is sorted and contains value points. The 2nd column contains probabilities. Probabilities should sum up to 1. |
sampleSize |
Sample size. |
seed |
An integer vector of size 1 or 4. Both seed a |
Random samples from pmf
as a numeric vector of size sampleSize
.
# Make a random PMF.
val = seq(0, 15, len = 100)
pmf = data.frame(val = val, P = dgamma(val, shape = 2, scale = 2))
pmf$P = pmf$P / sum(pmf$P)
pmfSample = SimJoint::LHSpmf(pmf, 1000, 123)
hist(pmfSample, breaks = 200)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.