My watch list
my.chemeurope.com  
Login  

Slice sampling



In mathematics and physics, Slice sampling is a type of Markov chain Monte Carlo sampling algorithm based on the observation that to sample a random variable one can sample uniformly from the region under the graph of its density function.

Contents

Implementation

To sample a random variable X with density f(x) we introduce an auxiliary variable Y and iterate as follows: Given a sample x we choose y uniformly at random from the interval [0,f(x)]; given y we choose x uniformly at random from the set f − 1[y,f(x)]. The sample of x is obtained by ignoring the y values.

Example

To sample from the normal distribution N(0,1) we first choose an initial x -- say 0. After each sample of x we choose y uniformly at random from [0, e^{-x^2/2}/\sqrt{2\pi}]; after each y sample we choose x uniformly at random from [ − α,α] where \alpha = \sqrt{-2\ln(y\sqrt{2\pi})}.

An implementation in the Macsyma language is:
slice(x):=block([y,alpha],

  y:random( exp(-x^2/2.0)/sqrt(2.0*dfloat(%pi))),
  alpha:sqrt(-2.0*ln(y*sqrt(2.0*dfloat(%pi)))),
  x:signum(random())*random(alpha)

);

See also

References

  • Radford M. Neal, "Slice Sampling". The Annals of Statistics, 31(3):705-767, 2003.
 
This article is licensed under the GNU Free Documentation License. It uses material from the Wikipedia article "Slice_sampling". A list of authors is available in Wikipedia.
Your browser is not current. Microsoft Internet Explorer 6.0 does not support some functions on Chemie.DE