ArticleslgStudy

science

Importance sampling

Importance sampling is a science 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 Importance sampling rather than just read about it. In short: Importance sampling is a Monte Carlo method for evaluating properties of a particular distribution, while only having samples generated from a different distribution than the distribution of interest. Its introduction in statistics is generally attributed to a paper by Teun Kloek and Herman K. van Dijk in 1978, but its precursors can be found in statistical physics as early as 1949.

Key takeaways

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

Reference excerpt

Importance sampling is a Monte Carlo method for evaluating properties of a particular distribution, while only having samples generated from a different distribution than the distribution of interest. Its introduction in statistics is generally attributed to a paper by Teun Kloek and Herman K. van Dijk in 1978, but its precursors can be found in statistical physics as early as 1949. Importance sampling is also related to umbrella sampling in computational physics. Depending on the application, the term may refer to the process of sampling from this alternative distribution, the process of inference, or both.

Basic theory Let X:Ω→ℝ be a random variable in some probability space (Ω,ℱ,P). We wish to estimate the expected value of X under P, denoted 𝔼P[X]. If we have statistically independent random samples X1,…,Xn, generated according to P, then an empirical estimate of 𝔼P[X] is just

𝔼^P[X]=1n∑i=1nXiwhereXi∼P(X) and the precision of this estimate depends on the variance of X:

varP[𝔼^P[X]]=varP[X]n. The basic idea of importance sampling is to sample from a different distribution to lower the variance of the estimation of 𝔼P[X], or when sampling directly from P is difficult. This is accomplished by first choosing a random variable Y≥0 such that 𝔼P[Y]=1 and that P-almost everywhere Y(ω)≠0. With the variable Y we define a probability Q that satisfies

𝔼P[X]=𝔼Q[XY]. The variable X/Y will thus be sampled under Q to estimate 𝔼P[X] as above and this estimation is improved when

varQ[XY]<varP[X]. When X is of constant sign over Ω, the best variable Y would clearly be Y∗=X𝔼P[X]≥0, so that X/Y∗ is the searched constant 𝔼P[X] and a single sample under Q∗ suffices to give its value. Unfortunately we cannot take that choice, because 𝔼P[X] is precisely the value we are looking for! However this theoretical best case Y∗ gives us an insight into what importance sampling does: for all x∈ℝ, the density of Q∗ at X=x can be written as

Q∗(X∈[x;x+dx])=∫ω∈{X∈[x;x+dx]}X(ω)𝔼P[X]dP(ω)=1𝔼P[X]xP(X∈[x;x+dx]). To the right, xP(X∈[x;x+dx]) is one of the infinitesimal elements that sum up to 𝔼P[X]:

𝔼P[X]=∫−∞+∞xP(X∈[x;x+dx]) therefore, a good probability change Q in importance sampling will redistribute the law of X so that its samples' frequencies are sorted directly according to their contributions in 𝔼P[X] as opposed to 𝔼P[1]. Hence the name "importance sampling." Importance sampling is often used as a Monte Carlo integrator. When P is the uniform distribution over Ω=ℝ, the expectation 𝔼P[X] corresponds to the integral of the real function X:ℝ→ℝ.

Application to probabilistic inference Such methods are frequently used to estimate posterior densities or expectations in state and/or parameter estimation problems in probabilistic models that are too hard to treat analytically. Examples include Bayesian networks and importance weighted variational autoencoders.

Application to simulation Importance sampling is a variance reduction technique that can be used in the Monte Carlo method. The idea behind importance sampling is that certain values of the input random variables in a simulation have more impact on the parameter being estimated than others. If these "important" values are emphasized by sampling more frequently, then the estimator variance can be reduced. Hence, the basic methodology in importance sampling is to choose a distribution which "encourages" the important values. This use of "biased" distributions will result in a biased estimator if it is applied directly in the simulation. However, the simulation outputs are weighted to correct for the use of the biased distribution, and this ensures that the new importance sampling estimator is unbiased. The weight is given by the likelihood ratio, that is, the Radon–Nikodym derivative of the true underlying distribution with respect to the biased simulation distribution. The fundamental issue in implementing importance sampling simulation is the choice of the biased distribution which encourages the important regions of the input variables. Choosing or designing a good biased distribution is the "art" of importance sampling. The rewards for a good distribution can be huge run-time savings; the penalty for a bad distribution can be longer run times than for a general Monte Carlo simulation without importance sampling. Consider X to be the sample and f(X)g(X) to be the likelihood ratio, where f is the probability density (mass) function of the desired distribution and g is the probability density (mass) function of the biased/proposal/sample distribution. Then the problem can be characterized by choosing the sample distribution g that minimizes the variance of the scaled sample:

g∗=mingvarg(Xf(X)g(X)). It can be shown that the following distribution minimizes the above variance:

g∗(X)=|X|f(X)∫|x|f(x)dx. Notice that when X≥0, this variance becomes 0.

Mathematical approach Consider estimating by simulation the probability pt of an event X≥t, where X is a random variable with cumulative distribution function F(x) and probability density function f(x)=F′(x), where prime denotes derivative. A K-length independent and identically distributed (i.i.d.) sequence Xi is generated from the distribution F, and the number kt of random variables that lie above the threshold t are counted. The random variable kt is characterized by the Binomial distribution

P(kt=k)=(Kk)ptk(1−pt)K−k,k=0,1,…,K. One can show that 𝔼[kt/K]=pt, and var⁡[kt/K]=pt(1−pt)/K, so in the limit K→∞ we are able to obtain pt. Note that the variance is low if pt≈1. Importance sampling is concerned with the determination and use of an alternate density function f∗(for X), usually referred to as a biasing density, for the simulation experiment. This density allows the event X≥t to occur more frequently, so the sequence lengths K gets smaller for a given estimator variance. Alternatively, for a given K, use of the biasing density results in a variance smaller than that of the conventional Monte Carlo estimate. From the definition of pt, we can introduce f∗ as below.

pt=𝔼[1{X≥t}]=∫1{x≥t}f(x)f∗(x)f∗(x)dx=𝔼∗[1{X≥t}W(X)] where

W(⋅)≡f(⋅)f∗(⋅) is a likelihood ratio and is referred to as the weighting function. The last equality in the above equation motivates the estimator

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with Importance sampling

Start with the simplest possible case. Write down what Importance sampling claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, 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 Importance 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 Importance 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 Importance sampling

In research
Importance sampling appears in science 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 Importance 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
Importance sampling is common in secondary-school and first-year university syllabi. It links to neighbouring topics Monte Carlo methods, Stochastic simulation, Variance reduction, so understanding it makes those chapters shorter.
In everyday life
Look for Importance 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.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Importance sampling” →

How to study Importance sampling in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Importance 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 Importance sampling out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Importance sampling in simple terms?

Importance sampling is a Monte Carlo method for evaluating properties of a particular distribution, while only having samples generated from a different distribution than the distribution of interest. Its introduction in statistics is generally attributed to a paper by Teun Kloek and Herman K. van…

Why does Importance sampling matter?

Because it connects several science 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 Importance 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 Importance sampling.

Tags

  • Monte Carlo methods
  • Stochastic simulation
  • Variance reduction

Keep exploring