LHSpmf {SimJoint} | R Documentation |
Sample from probability mass function
Description
Sample from a probability mass function (PMF) via Latin hypercube sampling.
Usage
LHSpmf(pmf, sampleSize, seed)
Arguments
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 |
Value
Random samples from pmf
as a numeric vector of size sampleSize
.
Examples
# 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)
[Package SimJoint version 0.3.12 Index]