Rejection Sampling
Module that contains function that performs rejection sampling.
- raises ValueError:
Error raised if bounds provided are of different dimensions
- return:
Accepted samples
- rtype:
ndarray
- monte.rejection_sampling.rejection(pdf, lower_bounds, upper_bounds, n)[source]
Performs rejection sampling from a distribution whose probability density/mass function is specified in pdf.
- Parameters:
pdf (callable) – Probability density/mass function of a distribution that we want to sample from
lower_bounds (ndarray) – Lower bound(s) of the sampling region
upper_bounds (ndarray) – Upper bound(s) of the sampling region
n (int) – Total number of samples (both rejected and accepted)
- Raises:
ValueError – Error raised if bounds provided are of different dimensions
- Returns:
Accepted samples
- Return type:
ndarray