rejection_sampler: Rejection sampler for DS convex polytopes

Description Usage Arguments Value Examples

View source: R/rejection_sampler.R

Description

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.

Usage

1
rejection_sampler(counts, maxnattempts = 1e+05)

Arguments

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.

Value

A list with the following entries:

Examples

1
2
3
4
5
## Not run: 
rejection_sampler(c(1,2,3))
rejection_sampler(c(6,0,5,0))

## End(Not run)

pierrejacob/montecarlodsm documentation built on June 16, 2021, 1:06 p.m.