Page updated:
April 14, 2020
Author: Curtis Mobley
View PDF
Introduction
This page is the ﬁrst of several on Monte Carlo techniques for solving the Radiative Transfer Equation. As an RTE solution technique, these pages could be considered as Level 2 material under the Radiative Transfer Theory chapter. However, because of the importance of Monte Carlo techniques in a wide range of scientiﬁc areas, they warrant a chapter unto themselves.
As used to solve the RTE, Monte Carlo techniques refer to algorithms that use probability theory and random numbers to simulate the fates of numerous photons propagating through a medium. Various averages over ensembles of large numbers of simulated photon trajectories give statistical estimates of radiances, irradiances, and other quantities of interest.
Monte Carlo techniques were developed in the 1940s for studies of neutron transport as needed for the design of nuclear weapons (Metropolis, 1949), (Eckhardt, 1987). The name Monte Carlo was at ﬁrst a code name for this classiﬁed research. The name was well chosen because probability and statistics lie at the heart of both the simulation techniques and the gambling games played at the legendary Monte Carlo Casino in Monaco. Monte Carlo techniques are now highly developed and are used to solve many types of problems in physical and biological sciences; ﬁnance, economics, and business; engineering; computer graphics for movie production, and pure mathematics.
An essential feature of Monte Carlo simulation is that the known probability of occurrence of each separate event in a sequence of events is used to estimate the probability of the occurrence of the entire sequence. In the photon setting, the known probabilities that a photon will travel a certain distance, be scattered through a certain angle, reﬂect oﬀ on a surface in a certain direction, etc., are used to estimate the probability that a photon emitted from a source at one location will travel through the medium and eventually be recorded by a detector at a diﬀerent location.
The strengths of Monte Carlo techniques are that
 They are conceptually simple. The methods are based on a straightforward mimicry of nature, which in itself endows them with a certain elegance.
 They are very general. Monte Carlo simulations can be used to solve problems for any geometry (e.g., 3D volumes with imbedded objects), incident lighting, scattering phase functions, etc. It is relatively easy to include polarization and time dependence.
 They are instructive. The solution algorithms highlight the fundamental processes of absorption and scattering, and they make clear the connections between the photonlevel and the energylevel formulations of radiative transfer theory.
 They are simple to program. The resulting computer code can be very simple, and the tracing of photons is well suited to parallel processing.
The weaknesses of Monte Carlo techniques are that
 They provide no insight into the underlying mathematical structure of radiative transfer theory. The simulations simply accumulate the results of tracing large numbers of photons, each of which is independent of the others.
 They can be computationally very ineﬃcient. Monte Carlo simulation is a “brute force” technique. If care is not taken, much of the computational time can be expended tracing photons that never contribute to the solution, e.g., because they never intercept a simulated detector.
 They are not well suited for some types of problems. For example, computations of radiance at large optical depths can require unacceptably large amounts of computer time because the number of solar photons penetrating the ocean decreases exponentially with the optical depth. Likewise, the simulation of a point source and a point (or very small) detector is diﬃcult. Monte Carlo techniques are based on tracking individual particles, i.e., photons, and thus cannot address wave phenomena such as diﬀraction.
This page discusses probability distributions and how they are sampled in Monte Carlo simulations. Subsequent pages discuss how photon tracks are simulated, computational tricks for speeding up calculations and improving the accuracy of the statistical estimates, and the design of Monte Carlo simulations for particular problems.
Probability Functions
As a photon travels through a medium, the distance it goes between interactions with the medium, whether it will be absorbed or scattered in a given interaction, the new direction it will travel after a scattering event, etc. are all random variables. In mathematics it is customary to let a capital letter, e.g. $X$, denote a random variable (such as the distance a photon travels) and to let a lower case letter, $x$ in this case, denote a value of $X$, e.g. $x=2.2\phantom{\rule{0.3em}{0ex}}\phantom{\rule{0.3em}{0ex}}m$ if $X$ is distance. Let $X$ be any such random variable that is deﬁned over a range of values ${x}_{1}$ to ${x}_{2}$. If $X$ is distance traveled, ${x}_{1}=0$ and ${x}_{2}=\infty $; if $X$ is a polar scattering angle, ${x}_{1}=0$ and ${x}_{2}=\pi $ or 180 deg, and so on.
The probability density function (pdf) for $X$, denoted ${p}_{X}\left(x\right)$, is a nonnegative function such that ${p}_{X}\left(x\right)dx$ is the probability (a number between 0 and 1) that $X$ has a value between $x$ and $x+dx$. A pdf must satisfy the normalization
$${\int}_{{x}_{1}}^{{x}_{2}}{p}_{X}\left(x\right)dx=1\phantom{\rule{0.3em}{0ex}}.$$  (1) 
That is, the probability is 1 that $X$ will have some value in its allowed domain. The cumulative distribution function (cdf) is a function ${P}_{X}\left(x\right)$ giving the probability that the random variable $X$ will have a numerical value less than or equal to $x$. The cdf is obtained from the corresponding pdf via
$${P}_{X}\left(x\right)={\int}_{{x}_{1}}^{x}{p}_{X}\left({x}^{\prime}\right)d{x}^{\prime}\phantom{\rule{0.3em}{0ex}}.$$ 
Note that a pdf has units of 1/{units of x} and can have a magnitude greater than 1 for some values of $x$, whereas a cdf is nondimensional and grows monotonically from 0 at $x={x}_{1}$ to 1 at $x={x}_{2}$.
The mean or average value of $X$ is given by
$${\mu}_{X}={\int}_{{x}_{1}}^{{x}_{2}}x\phantom{\rule{0.3em}{0ex}}{p}_{X}\left(x\right)dx\phantom{\rule{0.3em}{0ex}},$$ 
and the variance of $X$ is given by
$${\sigma}_{X}^{2}={\int}_{{x}_{1}}^{{x}_{2}}{\left(x{\mu}_{X}\right)}^{2}\phantom{\rule{0.3em}{0ex}}{p}_{X}\left(x\right)dx={\int}_{{x}_{1}}^{{x}_{2}}{x}^{2}\phantom{\rule{0.3em}{0ex}}{p}_{X}\left(x\right)dx{\mu}_{X}^{2}\phantom{\rule{0.3em}{0ex}}.$$ 
The pdf for a random variable that can have values only between 0 and 1 is fundamental to Monte Carlo simulation. Let $\Re $ be a random variable drawn from the unit interval between 0 and 1 such that $\Re $ is equally likely to have any value $0\le \U0001d52f\le 1$ on the interval from 0 to 1. The pdf for $\Re $ is
$\Re $ is said to have a uniform 0 to 1 distribution, denoted by $\Re \sim U\left[0,1\right]$.
We wish to use a randomly drawn value of $\Re $, which is a known number $\U0001d52f$, to determine a value for a random variable $X$. This is done by regarding going from $\Re $ to $X$ as a change of variables. Then the probablity that $\Re $ lies between $\U0001d52f$ and $\U0001d52f+d\U0001d52f$ is the same as the probability that $X$ lies between $x$ and $x+dx$. Thus
$${\int}_{0}^{\U0001d52f}{p}_{\Re}\left({\U0001d52f}^{\prime}\right)d{\U0001d52f}^{\prime}={\int}_{{x}_{1}}^{x}{p}_{X}\left({x}^{\prime}\right)d{x}^{\prime}$$ 
Because ${p}_{\Re}\left(\U0001d52f\right)$ is known from Eq. (2), the lefthand integral can be evaluated to obtain
$$\U0001d52f={\int}_{{x}_{1}}^{x}{p}_{X}\left({x}^{\prime}\right)d{x}^{\prime}={P}_{X}\left(x\right)$$ 
The fundamental principle of Monte Carlo simulation states that the equation
𝔯 = P
The next sections illustrate how this principle is applied for speciﬁc examples of determining photon path lengths and scattering angles.
Determining Photon Path Lengths
Recall from the derivation of the RTE that radiance in a particular direction $\left(\mathit{\theta},\varphi \right)$ decays due to absorption and scattering out of the beam according to
$$\frac{dL\left(r,\mathit{\theta},\varphi \right)}{dr}=c\left(r\right)L\left(r,\mathit{\theta},\varphi \right)\phantom{\rule{0.3em}{0ex}},$$ 
which integrates to give
$$L\left(r,\mathit{\theta},\varphi \right)=L\left(0,\mathit{\theta},\varphi \right){e}^{{\int}_{0}^{r}c\left({r}^{\prime}\right)d{r}^{\prime}}\phantom{\rule{0.3em}{0ex}},$$ 
where $c\left(r\right)$ is the beam attenuation coeﬃcient and $r$ is the distance from some starting point. In terms of the optical path length $\tau ={\int}_{0}^{r}c\left({r}^{\prime}\right)d{r}^{\prime}$ this is
$$L\left(\tau ,\mathit{\theta},\varphi \right)=L\left(0,\mathit{\theta},\varphi \right){e}^{\tau}\phantom{\rule{0.3em}{0ex}}.$$ 
This experimentally established exponential decay of radiance can be explained in terms of the fate of individual photons if the probability of any particular photon being absorbed or scattered out of the incident direction between $\tau $ and $\tau +d\tau $ is
$${p}_{T}\left(\tau \right)d\tau ={e}^{\tau}d\tau $$ 
Note that this ${p}_{T}\left(\tau \right)$ satisﬁes the normalization condition (1) with ${x}_{1}=0$ and ${x}_{2}=\infty $. The corresponding cdf is ${P}_{T}\left(\tau \right)=1{e}^{\tau}$. Drawing a random number $\U0001d52f$ from a $U\left[0,1\right]$ distribution and solving
$$\U0001d52f={P}_{T}\left(\tau \right)=1{e}^{\tau}$$ 
for $\tau $ gives
$$\tau =ln\left(1\U0001d52f\right)\phantom{\rule{0.3em}{0ex}}.$$ 
Because $1\Re $ is also uniformly distributed on $\left[0,1\right]$, we can just as well use
$$\tau =ln\left(\U0001d52f\right)$$ 
to determine $\tau $. Optical distances randomly chosen in this manner, when applied to many photons, are consistent with the exponential decay of radiance with distance traveled. If the water is homogeneous, so that $c\left(r\right)$ does not depend on $r$, then $\tau =c\phantom{\rule{0.3em}{0ex}}r$ and the geometric distance a photon travels is given by
$$r=\frac{1}{c}ln\left(\U0001d52f\right)\phantom{\rule{0.3em}{0ex}}.$$ 
Note that the average distance a photon travels is given by
$${\mu}_{T}={\int}_{0}^{\infty}\tau {e}^{\tau}d\tau =1$$ 
or, for homogeneous water,
$${\mu}_{R}=\frac{1}{c}\phantom{\rule{0.3em}{0ex}}.$$ 
The average distance a photon travels between an absorption or scattering interaction with the water is called the mean free path between interactions. Likewise, the standard deviation ${\sigma}_{T}$, which is the square root of the variance ${\sigma}_{T}^{2}$, of the optical distance traveled is also 1, or ${\sigma}_{R}=1\u2215c$. Thus photons travel on average one optical path length, or $1\u2215c$ meters, but with a large spread of values about that distance.
Determining Scattering Angles
Scattering is an inherently threedimensional process and must be speciﬁed by both polar $\left(\psi \right)$ and azimuthal $\left(\chi \right)$ scattering angles. The scattering phase function $\stackrel{\u0303}{\beta}\left({\psi}^{\prime},{\chi}^{\prime}\to \psi ,\chi \right)$ can be interpreted as a pdf for scattering from an incident direction $\left({\psi}^{\prime},{\chi}^{\prime}\right)$ to a ﬁnal direction $\left(\psi ,\chi \right)$, per unit of solid angle. If we pick a spherical coordinate system centered on the incident direction $\left({\psi}^{\prime},{\chi}^{\prime}\right)$ and recall the expression for an element of solid angle in spherical coordinates, then we can write
$$\stackrel{\u0303}{\beta}\left({\psi}^{\prime},{\chi}^{\prime}\to \psi ,\chi \right)\phantom{\rule{0.3em}{0ex}}d\Omega \left(\psi ,\chi \right)=\stackrel{\u0303}{\beta}\left(\psi ,\chi \right)\phantom{\rule{0.3em}{0ex}}sin\psi \phantom{\rule{0.3em}{0ex}}d\psi \phantom{\rule{0.3em}{0ex}}d\chi \phantom{\rule{0.3em}{0ex}}.$$ 
Ocean water is usually well described as isotropic medium, which means that there are no optically preferred directions. (This is not the case, for example, in a cirrus cloud with nonrandomly oriented ice crystals.) In that case, the polar and azimuthal scattering angles are independent, and we can write
$$\stackrel{\u0303}{\beta}\left(\psi ,\chi \right)\phantom{\rule{0.3em}{0ex}}sin\psi \phantom{\rule{0.3em}{0ex}}d\psi \phantom{\rule{0.3em}{0ex}}d\chi ={p}_{\Psi}\left(\psi \right)\phantom{\rule{0.3em}{0ex}}d\psi \phantom{\rule{0.3em}{0ex}}{p}_{X}\left(\chi \right)\phantom{\rule{0.3em}{0ex}}d\chi $$ 
For an unpolarized beam, the azimuthal angle is equally likely to have any value from 0 to 360 deg, or 0 to $2\pi $ radians. Thus the pdf for azimuthal scattering is ${p}_{X}\left(\chi \right)=1\u2215\left(2\pi \right)$, the cdf is ${P}_{X}\left(\chi \right)=\chi \u2215\left(2\pi \right)$, and $\chi $ is determined by $\chi =2\pi \U0001d52f$.
Using this ${p}_{X}\left(\chi \right)$ in the previous equation allows us to identify the pdf for the polar angle as
$${p}_{\Psi}\left(\psi \right)=2\pi \stackrel{\u0303}{\beta}\left(\psi \right)sin\psi $$ 
Recall from the discussion of the VSF that phase functions satisfy the normalization
$$2\pi {\int}_{0}^{\pi}\stackrel{\u0303}{\beta}\left(\psi \right)sin\psi \phantom{\rule{0.3em}{0ex}}d\psi =1\phantom{\rule{0.3em}{0ex}},$$ 
so this function ${p}_{\Psi}\left(\psi \right)$ is indeed a pdf. Therefore, to determine the polar scattering angle, we draw a $U\left[0,1\right]$ random number $\U0001d52f$ as always and solve
$$\U0001d52f=2\pi {\int}_{0}^{\psi}\stackrel{\u0303}{\beta}\left({\psi}^{\prime}\right)\phantom{\rule{0.3em}{0ex}}sin{\psi}^{\prime}\phantom{\rule{0.3em}{0ex}}d{\psi}^{\prime}$$  (3) 
for $\psi $.
In general, Eq. (3) must be solved numerically because of the complicated shape of most phase functions, or when the phase function is deﬁned by tabulated data at a ﬁnite number of scattering angles and is ﬁt with a spline (or other) function to generate a continuous function of scattering angle. However, a few commonly used phase functions allow this equation to be solved analytically. The simplest case, isotropic scattering, is instructive.
Isotropic Scattering. The phase function for isotropic scattering is $\stackrel{\u0303}{\beta}\left(\psi \right)=\frac{1}{4\pi}$. Substituting this into Eq. (3) leads to
$$\psi ={cos}^{1}\left(12\U0001d52f\right)$$ 
for the determination of the scattering angle. This result may look peculiar until it is remembered that isotropic scattering means that scattering is equally likely into any element of solid angle, not equally likely at every scattering angle $\psi $. Figure 1 illustrates this important point. Scattering from a collimated beam is simulated two diﬀerent ways. The scattering events occur at the center of a sphere, and the points plotted on the surface of the sphere show the scattering direction. The arrow at the “north pole” represents the direction of the unscattered beam and a scattering angle of 0. The blue lines are lines of constant scattering angle $\psi $, with the thick line at the “equator” being $\psi =90$ deg. In the left panel, the polar scattering angle $\psi $ was drawn from a $U\left[0,180\right]$ distribution, i.e., any value of $\psi $ between 0 and 180 deg was equally likely. The right panel drew $\psi $ from the ${cos}^{1}\left(12\U0001d52f\right)$ distribution. In both simulations the azimuthal scattering angle $\chi $ was drawn from a $U\left[0,360\right]$ distribution. It is visually clear from the left panel that the uniform distribution of $\psi $ values gives too many points near the north pole of the ﬁgure, i.e., too many points with scattering angles near 0. The right panel shows an even distribution of points per unit area of the surface of the sphere, i.e., per unit solid angle in any direction.
Table 1 displays various phase functions and the formulas obtained from solving $\U0001d52f={P}_{\Psi}\left(\psi \right)$ used to determine the corresponding scattering angles.
Name  Phase Function $\stackrel{\u0303}{\beta}\left(\psi \right)$  $\psi $ formula 
isotropic  $\frac{1}{4\pi}$  $\psi ={cos}^{1}\left(12\U0001d52f\right)$ 
Henyey  $\frac{1}{4\pi}\frac{1{g}^{2}}{{\left(1+{g}^{2}2gcos\psi \right)}^{3\u22152}}$  $\psi ={cos}^{1}\left[\frac{1+{g}^{2}}{2g}\frac{1}{2g}{\left(\frac{1{g}^{2}}{1+g2g\U0001d52f}\right)}^{2}\right]$

Rayleigh  $\frac{3}{16\pi}\left(1+{cos}^{2}\psi \right)$  $\psi ={cos}^{1}\left[{\left(A+B\right)}^{1\u22153}+{\left(AB\right)}^{1\u22153}\right]$

cosine or  $\frac{1}{\pi}cos\psi $
if
$0\le \psi \le \frac{\pi}{2}$
 $\psi ={sin}^{1}\left(\sqrt{\U0001d52f}\right)$ 
arbitrary  any
$\stackrel{\u0303}{\beta}\left(\psi \right)$
that  must solve 
The widely used FournierForand phase function is
$$\begin{array}{llll}\hfill {\stackrel{\u0303}{\beta}}^{FF}\left(\psi \right)=& \phantom{\rule{1em}{0ex}}\frac{\phantom{\rule{1em}{0ex}}1}{4\pi {\left(1\delta \right)}^{2}{\delta}^{\nu}}\phantom{\rule{0.3em}{0ex}}\left[\nu \phantom{\rule{0.3em}{0ex}}\left(1\delta \right)\left(1{\delta}^{\nu}\right)+\left[\delta \left(1{\delta}^{\nu}\right)\nu \left(1\delta \right)\right]\phantom{\rule{0.3em}{0ex}}{sin}^{2}\left(\frac{\psi}{2}\right)\right]\phantom{\rule{2em}{0ex}}& \hfill & \phantom{\rule{2em}{0ex}}\\ \hfill +& \frac{1{\delta}_{180}^{\nu}}{16\pi \left({\delta}_{180}1\right){\delta}_{180}^{\nu}}\left(3{cos}^{2}\psi 1\right)\phantom{\rule{0.3em}{0ex}}\phantom{\rule{0.3em}{0ex}},\phantom{\rule{2em}{0ex}}& \hfill & \phantom{\rule{2em}{0ex}}\end{array}$$where
$$\nu =\frac{3\mu}{2}\phantom{\rule{1em}{0ex}}\phantom{\rule{1em}{0ex}}\phantom{\rule{1em}{0ex}}\phantom{\rule{1em}{0ex}}\phantom{\rule{1em}{0ex}}and\phantom{\rule{1em}{0ex}}\phantom{\rule{1em}{0ex}}\phantom{\rule{1em}{0ex}}\phantom{\rule{1em}{0ex}}\phantom{\rule{1em}{0ex}}\delta =\frac{4}{3{\left(n1\right)}^{2}}\phantom{\rule{0.3em}{0ex}}{sin}^{2}\left(\frac{\psi}{2}\right)\phantom{\rule{0.3em}{0ex}},$$ 
$n$ is the real index of refraction of the particles, $\mu $ is the slope parameter of the hyperbolic distribution, and ${\delta}_{180}$ is $\delta $ evaluated at $\psi =180\phantom{\rule{1em}{0ex}}deg$. This phase function has an analytic cdf (Fournier and Jonasz, 1999)
$$\begin{array}{llll}\hfill {P}_{\Psi}^{FF}\left(\psi \right)=& \phantom{\rule{1em}{0ex}}\frac{1}{\left(1\delta \right){\delta}^{\nu}}\left[\left(1{\delta}^{\nu +1}\right)\left(1{\delta}^{\nu}\right){sin}^{2}\left(\psi \u22152\right)\right]\phantom{\rule{2em}{0ex}}& \hfill & \phantom{\rule{2em}{0ex}}\\ \hfill +& \phantom{\rule{1em}{0ex}}\frac{1}{8}\frac{1{\delta}_{180}^{\nu}}{\left({\delta}_{180}1\right){\delta}_{180}^{\nu}}\phantom{\rule{0.3em}{0ex}}cos\psi \phantom{\rule{0.3em}{0ex}}{sin}^{2}\psi \phantom{\rule{0.3em}{0ex}}.\phantom{\rule{2em}{0ex}}& \hfill \text{(4)}\end{array}$$ However, solving $\U0001d52f={P}_{\Psi}^{FF}\left(\psi \right)$ for $\psi $ (even if possible) would give a formula so complicated that it is numerically more eﬃcient to use Eq. (3) for ${P}_{\Psi}^{FF}\left(\psi \right)$ to build up a table of $\psi $ vs. ${P}_{\Psi}^{FF}\left(\psi \right)$ values for closely spaced values of $\psi $ and the given $n$ and $\mu $ parameters, and then to interpolate within this table to obtain values of $\psi $ as $\U0001d52f$ values are drawn in the course of a simulation. This is illustrated in Fig. 2, which shows a FourierForand cdf for values of $n$ and $\mu $ that give a best ﬁt to the Petzold average particle phase function phase function. The blue arrows show how drawing a value of $\U0001d52f=0.7$ leads to a scattering angle of about 10 deg. When working with tabulated data for highly peaked phase functions, it is usually adequate to use linear interpolation between the tabulated values.