Sampling¶
-
maoud.sampling.
rejection_sampling
(pdf, x, n_samples, *args)[source]¶ This is maybe the simplest implementation of the acceptance-rejection sampler.
Parameters: pdf : callable
The analytical formulation of the density function to get samples from.
x : array
The support of the pdf.
n_samples : int
The sample size.
args : list
List of additional arguments to be passed to
pdf
.Returns: accepted_samples : array
Array containing samples from
pdf
acceptance_fraction : float
The mean ratio between the number of accepted samples and the number of generated ones.