ArticleslgStudy

mathematics

Slice sampling

Slice sampling is a mathematics topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Slice sampling rather than just read about it. In short: Slice sampling is a type of Markov chain Monte Carlo algorithm for pseudo-random number sampling, i.e. for drawing random samples from a statistical distribution. The method is based on the fact that to sample a random variable one can sample uniformly from the region under the graph of its density function.

Slice sampling — main illustration
Slice sampling — illustration

Key takeaways

  • Slice sampling belongs to mathematics; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Slice sampling to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Slice sampling from memory before moving on to harder problems.

Reference excerpt

Slice sampling is a type of Markov chain Monte Carlo algorithm for pseudo-random number sampling, i.e. for drawing random samples from a statistical distribution. The method is based on the fact that to sample a random variable one can sample uniformly from the region under the graph of its density function.

Motivation Sampling a random variable x {\displaystyle x} from a given probability density function f ( x ) {\displaystyle f(x)} is a common task in statistics. The figure (below left) sketches the graph of f ( x ) {\displaystyle f(x)} , where the height at x {\displaystyle x} corresponds to the likelihood at that point. In the case of uniform distribution, each value of x {\displaystyle x} would have the same likelihood of being sampled, and the corresponding function would be f ( x ) = y {\displaystyle f(x)=y} for some constant y {\displaystyle y} . Instead of the original black line, a uniform distribution is denoted by the blue line in the second figure (below right). In order to sample x {\displaystyle x} in a manner which will retain the distribution f ( x ) {\displaystyle f(x)} , a sampling technique that takes into account the varied likelihoods for each range of f ( x ) {\displaystyle f(x)} must be used.

Method Slice sampling, in its simplest form, samples uniformly from underneath the curve f ( x ) {\displaystyle f(x)} without the need to reject any points, as follows:

Choose a starting value x 0 {\displaystyle x_{0}} for which f ( x 0 ) > 0 {\displaystyle f(x_{0})>0}

Sample a y {\displaystyle y} value uniformly between 0 {\displaystyle 0} and f ( x 0 ) {\displaystyle f(x_{0})} . Draw a horizontal line across the curve at this y {\displaystyle y} position. Sample a point ( x , y ) {\displaystyle (x,y)} from the line segments within the curve. Repeat from step 2 using the new x {\displaystyle x} value. The motivation here is that one way to sample a point uniformly from within an arbitrary curve is first to draw thin uniform-height horizontal slices across the whole curve. Then, we can sample a point within the curve by randomly selecting a slice that falls at or below the curve at the x {\displaystyle x} -position from the previous iteration, then randomly picking an x {\displaystyle x} -position somewhere along the slice. By using the x {\displaystyle x} -position from the previous iteration of the algorithm, in the long run we select slices with probabilities proportional to the lengths of their segments within the curve. The most difficult part of this algorithm is finding the bounds of the horizontal slice, which involves inverting the function describing the distribution being sampled from. This is especially problematic for multi-modal distributions, where the slice may consist of multiple discontinuous parts. It is often possible to use a form of rejection sampling to overcome this, where we sample from a larger slice that is known to include the desired slice in question, and then discard points outside of the desired slice. This algorithm can be used to sample from the area under any curve, regardless of whether the function integrates to 1. In fact, scaling a function by a constant has no effect on the sampled x {\displaystyle x} -positions. This means that the algorithm can be used to sample from a distribution whose probability density function is only known up to a constant (i.e. whose normalizing constant is unknown), which is common in computational statistics.

… excerpt ends here. Continue reading the full article.

Illustrations

Slice sampling illustration
Slice sampling: For a given sample x, a value for y is chosen from [0, f(x)], which defines a "slice" of the distribution (shown by the solid horizontal line). In this case, there are two slices separated by an area outside the range of the distribution.
For a given sample x, a value for y is chosen from [0, f(x)], which defines a "slice" of the distribution (shown by the solid horizontal line). In this case, there are two slices separated by an area outside the range of the distribution.
Slice sampling: Finding a sample given a set of slices (the slices are represented here as blue lines and correspond to the solid line slices in the previous graph of f(x) ). a) A width parameter w is set. b) A region of width w is identified around a given point 
  
    
      
        
          x
          
            0
          
        
      
    
    {\displaystyle x_{0}}
  
. c) The region is expanded by w until both endpoints are outside of the considered slice. d) 
  
    
      
        
          x
          
            1
          
        
      
    
    {\displaystyle x_{1}}
  
 is selected uniformly from the region. e) Since 
  
    
      
        
          x
          
            1
          
        
      
    
    {\displaystyle x_{1}}
  
 lies outside the considered slice, the region's left bound is adjusted to 
  
    
      
        
          x
          
            1
          
        
      
    
    {\displaystyle x_{1}}
  
. f) Another uniform sample 
  
    
      
        x
      
    
    {\displaystyle x}
  
 is taken and accepted as the sample since it lies within the considered slice.
Finding a sample given a set of slices (the slices are represented here as blue lines and correspond to the solid line slices in the previous graph of f(x) ). a) A width parameter w is set. b) A region of width w is identified around a given point x 0 {\displaystyle x_{0}} . c) The region is expanded by w until both endpoints are outside of the considered slice. d) x 1 {\displaystyle x_{1}} is selected uniformly from the region. e) Since x 1 {\displaystyle x_{1}} lies outside the considered slice, the region's left bound is adjusted to x 1 {\displaystyle x_{1}} . f) Another uniform sample x {\displaystyle x} is taken and accepted as the sample since it lies within the considered slice.
Slice sampling illustration

Worked examples

Example 1 — a first encounter with Slice sampling

Start with the simplest possible case. Write down what Slice sampling claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In mathematics, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Slice sampling before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Slice sampling ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Slice sampling

In research
Slice sampling appears in mathematics research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Slice sampling in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Slice sampling is common in secondary-school and first-year university syllabi. It links to neighbouring topics Markov chain Monte Carlo, Non-uniform random numbers, so understanding it makes those chapters shorter.
In everyday life
Look for Slice sampling outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Slice sampling in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Slice sampling means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Slice sampling out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Slice sampling in simple terms?

Slice sampling is a type of Markov chain Monte Carlo algorithm for pseudo-random number sampling, i.e. for drawing random samples from a statistical distribution. The method is based on the fact that to sample a random variable one can sample uniformly from the region under the graph of its density…

Why does Slice sampling matter?

Because it connects several mathematics ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Slice sampling?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Slice sampling.

Tags

  • Markov chain Monte Carlo
  • Non-uniform random numbers

Keep exploring