wmpy.sampling.rejection.RejectionSampler¶
- class RejectionSampler(polytope, polynomial, seed=None)[source]¶
Bases:
objectThis class implements rejection sampling from a polynomial distribution with convex support.
Default constructor.
- Parameters:
polytope (
Polytope) – convex integration boundspolynomial (
Polynomial) – the target distribution
Methods
Draws a sample from a N-dimensional convex polytope using two-phases rejection.
- sample(n_samples, max_iterations=1)[source]¶
Draws a sample from a N-dimensional convex polytope using two-phases rejection.
Initially, samples are uniformly sampled in the enclosing axis-aligned bounding box of the polytope. The first rejection phase discards points that are outside the polytope. Then, the second rejection phase ensures that samples are drawn from the target polynomial distribution.
The procedure tries to sample n_samples points up to max_iterations, returning M <= n_samples points.