Description Usage Arguments Value Examples
Samples with replacement from given log-probability vector
1 | sample_logp(x, size, lp_vec)
|
x |
a vector of possible outcomes |
size |
number of samples to take, where sampling is with replacement |
lp_vec |
a numeric vector that contains the log-probabilities with which to sample. These probabilities might or not be normalized to sum to one. |
a sample of size size
from x
1 2 3 4 5 6 7 | K = 4
# unnormalized probability vector (on log-scale)
lq_vec = log(runif(K))
# sample first K letters according to lqvec
x = sample_logp(letters[1:K], 1000, lq_vec)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.