Adaptive rejection sampling in F#
Adaptive rejection sampling (derivative-free). Based on matlab implementation from PMTK3 library.
Compared to the original implementation in matlab, this version computes probabilities in log space which avoids numerical problems.
func
- Function which computes logarithm of a likelihood functiona
,b
- Starting points, a < b.domain
- Tuple offunc
boundaries. If the left boundary is -infinity, derivative off
ata
must be positive. If the right boundary is infinity, derivative off
atb
must be negative.nSamples
- Total number of samples that the sampler should return.
- Gilks W. 1992. Derivative-free adaptive rejection sampling for Gibbs sampling. In: Bernardo J.M., Berger J.O., Dawid A.P., and Smith A.F.M. (Eds.), Bayesian Statistics 4. Oxford University Press, xford, pp. 641โ665.
- Gilks W.R. and Wild P. 1992. Adaptive rejection sampling for Gibbs sampling. Applied Statistics 41: 337โ348.