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.