urhitro {Runuran} | R Documentation |
UNU.RAN random variate generator for continuous multivariate distributions with given probability density function (PDF). It is based on the Hit-and-Run algorithm in combinaton with the Ratio-of-Uniforms method (HITRO).
urhitro(n, dim=1, pdf, mode=NULL, thinning=1, burnin = 0, ...)
n |
size of required sample. |
dim |
number of dimensions of the distribution. (integer) |
pdf |
probability density function. (R function) |
mode |
location of the mode – optional. (numeric vector) |
thinning |
thinning factor. (positive integer) |
burnin |
lenght of burin-in phase. (positive integer) |
... |
(optional) arguments for pdf |
This is a Markov chain sampler that generates a sequence of continuous
random vectors with given probability density function. This function
must be provided by pdf
, a function which must return
non-negative numbers and which need not be normalized (i.e., it can be
any multiple of a density function).
Notice that MCMC samplers do not produce a sequence of independent variates. The drawn sample follows the target distribution only appropriately. Beware: MCMC sampling can be dangerous!
The algorithm works best with log-concave distributions. Other distributions work as well but convergence can be slower.
Josef Leydold and Wolfgang H"ormann unuran@statmath.wu-wien.ac.at.
R. Karawatzki, J. Leydold, and K. P"otzelberger (2005): Automatic Markov Chain Monte Carlo Procedures for Sampling from Multivariate Distributions. Research Report Series / Department of Statistics and Mathematics, Nr. 27, December 2005 Department of Statistics and Mathematics, Wien, Wirtschaftsuniv., 2005. http://epub.wu-wien.ac.at/dyn/virlib/wp/showentry?ID=epub-wu-01_8cb
runif
and .Random.seed
about random number
generation, unuran
for the UNU.RAN class.
## Create a sample of size 100 for a ## Gaussian distribution mvpdf <- function (x) { exp(-sum(x^2)) } x <- urhitro(20, dim=2, pdf=mvpdf) x ## use: ## mode at (0,0) ## thinning factor 3 ## (only every 3rd vector in the sequence is returned) ## burn-in of length 100 ## (the first 1000 vectors in the sequence are discarded) x <- urhitro(20, dim=2, pdf=mvpdf, mode=c(0,0), thinning=3, burnin=100) x