Description Usage Arguments Author(s) See Also Examples
Draw random samples from a probability mass function using the inverse transform sampling.
1 |
n |
An integer >= 1. |
pmf |
A probability mass function which takes elements of an ambient
space of pmf's support (i.e. an input that makes pmf return a probability)
in its first argument. This pmf has a finite |
support |
A vector which consists of the elements of the support
of |
... |
An additional argument of |
Junkyu Park
csum_N
,
dpmf
,
Evaluating a hard-to-evaluate pmf using pgf and DFT
1 2 3 4 5 6 7 8 9 10 11 12 | # Example 1: dfruit in dpmf example
# Generate 12 random samples from dfruit
rpmf(12, dfruit, c('apple', 'orange', 'neither'))
# Example 2: dX in csum_N example
# Generate 20 samples of X_i ~ dX
rpmf(20, dX, 0:5)
# Example 3: S = sum of iid X_i's, i = 1, ..., N,
# where N ~ Pois(3) and N independent of all X_i ~ dX (in Example 2)
# Generate 12 samples of S
result_X <- csum_N(dX, support = 0:5, lambda = 3)
M <- length(result_X)
rpmf(12, dpmf, 0:(M - 1), result_X)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.