Cumulative Distribution Function
Suppose that
is a
random variable. The
cumulative distribution function of
is the function
defined by
Joint Density Function
Suppose that
and
are real-valued
random variables. A function
is a
joint density function for
if, for every suitable set
,
Marginal Density Function
Suppose that
is a
joint density function. The
marginal density function of
is
Conditional Density Function
Suppose that
is a
joint density function and
. The
conditional density function of
given
is
Joint Density Factors as Marginal Times Conditional Density
Suppose that
is a
joint density. Then
whenever
.
Estimator
Suppose that
is a fixed quantity to be estimated. An
estimator for
is a real-valued
random variable whose values are used as approximations to
. In practice,
is often a function of random samples, so its value changes with the sampled outcomes while
stays fixed.
For example, might be the true average height of every adult in a country. Measuring every adult is unrealistic, so we randomly sample some people and compute a sample average . The true average is fixed, but the sample average is random because a different sample can give a different value.
Unbiased Estimator
Suppose that
is an
estimator for
. The estimator
is
unbiased if
Biased Estimator
Suppose that
is an
estimator for a fixed
. The
bias of
is the difference between the average value of the estimator and the target value:
The estimator is
biased if its bias is not
.
Monte Carlo Estimator
Suppose that
,
, and
is a
density function on
such that
whenever
. If
are independent samples with density
, the
Monte Carlo estimator for
is
Variance of an Average of Independent Identically Distributed Random Variables
Suppose that
are
independent identically distributed random variables with finite
variance. Then
Let
By
linearity of expectation,
Therefore
Now apply the
definition of variance:
To see the square expansion, first use distributivity on an arbitrary finite sum:
The terms with
are the diagonal terms
. The terms with
occur in pairs: for each
, the double sum contains both
and
, and these are equal. Hence
Applying this with
gives
Taking expectations and using
linearity of expectation,
The first expectation is
by the
definition of variance. The second expectation is
by the
definition of covariance. Hence
Since the random variables are independent, they are
uncorrelated, so each covariance term is
. Since they are identically distributed, each variance is
. Therefore
Finally, scaling by
scales variance by
, so
Monte Carlo Estimator Variance
Under the hypotheses of the
Monte Carlo estimator, define
If
has finite
variance, then
Mean Squared Error
Suppose that
is an
estimator for
. The
mean squared error of
is
Unbiased Estimator MSE is Variance
If
is an
unbiased estimator for
, then
Since
is unbiased,
. Substituting this into the
mean squared error gives
which is exactly the
variance of
.
Monte Carlo Efficiency
If
is an
estimator with finite positive
variance and expected runtime
, its
Monte Carlo efficiency is
Sample Variance
Suppose that , with , and let
The sample variance of is
Inversion Method
Suppose that
is a
cumulative distribution function that has an inverse
, and suppose that
. The
inversion method samples from
by setting
The inversion method is one way to turn a uniform random number into a random variable with a desired distribution. Start with , which is uniformly distributed on . If the desired cumulative distribution function is , then the interval has length , so . Choosing makes the event match the event . Thus the transformation reshapes uniform randomness so that the output has distribution .
Discrete Inversion Method
Suppose that are possible values with probabilities and
Let
If , the discrete inversion method returns when
where .
Discrete Inversion Method Has the Target Probabilities
Under the hypotheses of the
discrete inversion method,
The event is the event . Since is uniform on , the probability of this interval is its length:
Inversion Method Samples from the Target Distribution
Suppose that
is an invertible
cumulative distribution function,
, and
. Then
has cumulative distribution function
.
For any ,
Since a cumulative distribution function is non-decreasing, applying to both sides gives the equivalent event . Because ,
Therefore the cumulative distribution function of is .
For example, suppose we want density on . Its cumulative distribution function is . If is uniform on , set . Then
so has density . The random number generator only produced a uniform value; the transformation changed how often different output values occur.
Linear Function Density
Suppose that , not both , and define by
The normalized density proportional to is
Inversion Sampling for a Linear Function Density
Under the hypotheses of
linear function density, if
, then a sample from density
is
when
. Equivalently, to avoid cancellation,
The cumulative distribution function of is
Setting gives a quadratic equation in . Solving the quadratic and choosing the root in gives
Multiplying numerator and denominator by gives the equivalent form.
Change of Variables for Density Functions
Suppose that is an -dimensional random variable with density , and suppose that is a differentiable bijection whose Jacobian determinant is nonzero. If , then the density of is
For every suitable set ,
By the multivariable change of variables formula, with ,
Since this holds for every suitable , the displayed integrand is the density of .
Stratified Sampling
Suppose that a domain
is
partitioned into
disjoint measurable sets
.
Stratified sampling is the practice of estimating an integral over
by taking samples separately within each stratum
and combining the resulting estimates.
Stratified Monte Carlo Estimator
Suppose that is partitioned into measurable strata , with denoting the measure of . If is a Monte Carlo estimator for
then the stratified Monte Carlo estimator is
Stratified Sampling Does Not Increase Variance
Suppose that is partitioned into measurable strata , and samples are allocated proportionally to stratum measure: . If and are the mean and variance of under the uniform distribution on , and is the mean of under the uniform distribution on , then the stratified estimator has variance
while the unstratified estimator has variance
Hence stratification does not increase variance.
For stratum
, averaging
independent samples gives variance
by
variance of an average of independent identically distributed random variables. The stratified estimator is
, so independence of samples across strata gives
Substituting
gives the displayed stratified variance.
For unstratified sampling, the total variance decomposes into the average within-stratum variance plus the variance of the stratum means:
Averaging
independent samples divides this by
. Since each term
, the stratified variance is no larger.
Importance Sampling
Importance sampling estimates an integral
by drawing samples from a density and using the weighted terms
The density should be positive wherever is nonzero.
For example, to estimate , ordinary uniform sampling uses with density , so each weighted term is . Importance sampling could instead use the density , which samples more often near , where is larger. Then each weighted term is , for samples .
Ideal Importance Sampling Has Zero Variance for Nonnegative Integrands
Suppose that
and
. If
then each importance sampling term satisfies
Hence the
Monte Carlo estimator has zero variance.
By the definition of ,
whenever . When , this value occurs only where the density also vanishes and does not affect the estimator. Thus the estimator is constant almost surely, and a constant random variable has variance .
Multiple Importance Sampling
Multiple importance sampling estimates an integral by combining samples drawn from several densities . If is a weight function for density , then a typical weighted term has the form
Multiple Importance Sampling Estimator
Suppose that are sampling densities and that is sampled from , for . The multiple importance sampling estimator is
Multiple Importance Sampling Unbiasedness Conditions
The
multiple importance sampling estimator is unbiased for
if, whenever
,
and
whenever
.
Using
linearity of expectation and the definition of density,
The condition
where
makes the terms well-defined, and the remaining factors cancel:
Balance Heuristic
Suppose that are sampling densities and samples are drawn from . The balance heuristic assigns the weight
Balance Heuristic Weights Sum to One
If
, the
balance heuristic weights satisfy
Substitute the definition:
Power Heuristic
Suppose that are sampling densities, samples are drawn from , and . The power heuristic assigns the weight
MIS Compensation
Given a density and , the MIS compensated density is
whenever the denominator is positive.
Russian Roulette Estimator
Suppose that
is an
unbiased estimator for
, and let
be a Bernoulli random variable with
, independent of
. The
Russian roulette estimator is
Russian Roulette Estimator is Unbiased
By conditioning on the two values of the
Bernoulli random variable ,
Since
and constants pull out of expectation,
Since
is unbiased for
,
.
Russian Roulette Estimator with a Fallback Value
Suppose that is an estimator, , , and . The Russian roulette estimator with fallback value is
Russian Roulette with a Fallback Value Preserves Expectation
Since and ,
Pulling constants out of expectation gives
Splitting Estimator
Suppose that are samples from a density , and for each , the conditional samples are drawn from a conditional density . The splitting estimator for
is
Splitting Estimator is Unbiased
Under the hypotheses of the
splitting estimator,
By
linearity of expectation,
For each
, use the joint density factorization
:
The density factors cancel, so each summand has expectation
. Averaging
identical expectations leaves that same integral.