Description Usage Arguments Value Examples
View source: R/rejection_sampler.R
Implements a rejection sampler, as an alternative to the proposed Gibbs sampler. Only works for very small data sets, otherwise the number of attempts required to obtain a draw is prohibitively large. The sampler draws N uniform variables in the simplex of dimension K, and then checks whether the constraints are satisfied, specifically by checking whether a certain graph contains negative cycles. The implementation uses the "igraph" package for that.
1 | rejection_sampler(counts, maxnattempts = 1e+05)
|
counts |
a vector of counts, of length K, that could contain zeros. |
maxnattempts |
an integer indicating the number of trials to perform before giving up. |
A list with the following entries:
"etas": a KxK matrix if procedure succeeded, otherwise NULL.
"nattempts": an integer indicating the number of trials.
1 2 3 4 5 | ## Not run:
rejection_sampler(c(1,2,3))
rejection_sampler(c(6,0,5,0))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.