multivariate.metropolis.sample | R Documentation |
Generate a sample from a probability distribution with the Metropolis algorithm.
multivariate.metropolis.sample(target.dist, x0, sample.size, tuning=1)
univar.metropolis.sample(target.dist, x0, sample.size, tuning=1)
target.dist |
Target distribution; see |
x0 |
Numeric vector containing initial state. |
sample.size |
Sample size requested. |
tuning |
Proposal standard deviation |
These two functions implement variants of the Metropolis algorithm
for sampling a target distribution, following the interface
used by compare.samplers
.
multivariate.metropolis.sample
uses spherically symmetric
Gaussian proposals with marginal standard deviation equal to the
tuning
parameter. univar.metropolis.sample
updates
each coordinate in sequence using univariate Gaussian proposals
with standard deviation equal to the tuning
parameter.
So that these two functions are roughly comparable, with a
p
-dimensional target distribution,
multivariate.metropolis.sample
performs p
accept-reject
steps each time between observations, so that both functions
evaluate the log density a number of times roughly equal to p
times the sample size. While there are often efficiency optimizations
possible when only one coordinate is updated,
univar.metropolis.sample
does not support these; these two
samplers are included for comparison rather than for practical use.
A list with elements X
, evals
, and reject.rate
.
See compare.samplers
for more information on X
and
evals
. reject.rate
is the fraction of proposals
not accepted.
compare.samplers
,
adaptive.metropolis.sample
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.