Short Course on Computational Monte Carlo Methods: Fundamentals Shuang Zhao Assistant Professor Computer Science Department University of California, Irvine Shuang Zhao 1
Teaching Objective Introducing Monte Carlo integration As a stochastic quadrature method Advantages/disadvantages Introducing the stochastics model of light transport in tissue Show how these simple ideas can be extended to the simulation of light transport VP Short Course 2017 Shuang Zhao 2
Outline 1. Monte Carlo integration A powerful numerical tool for estimating complex integrals 2. Radiative transfer The physical framework governing light propagation in translucent materials (including human tissue) 3. Monte Carlo solution to the radiative transfer equation Basically, 1 + 2 Shuang Zhao 3
Shuang Zhao 4
Monte Carlo Integration VP Short Course 2017 Shuang Zhao 5
Why Monte Carlo? A powerful tool for numerically estimating complex integrals The gold standard approach to simulate light transport in tissue Advantages: Provides estimates with quantifiable uncertainty Adaptable to systems with complex geometries Shuang Zhao 6
Monte Carlo Integration A powerful framework for computing integrals Numerical Nondeterministic (i.e., using randomness) Scalable to high-dimensional problems Shuang Zhao 7
Random Variables (Discrete) random variable X Possible outcomes: x 1, x 2,, x n with probability masses p 1, p 2,, p n such that E.g., fair coin Outcomes: x 1 = head, x 2 = tail Probabilities: p 1 = p 2 = ½ Shuang Zhao 8
Random Variables (Continuous) random variable X Possible outcomes: with probability density function (PDF) p(x) satisfying Shuang Zhao 9
Strong Law of Large Numbers Let x 1, x 2,, x n be n independent observations (aka. samples) of X Sample mean Actual mean Shuang Zhao 10
Example: Evaluating π Unit circle S Let X be a point uniformly distributed in the square Let, then Circle area = π Square area = 4 Shuang Zhao 11
Example: Evaluating π Unit circle S Simple solution for computing π: Generate n samples x 1,, x n independently Circle area = π Square area = 4 Compute Live demo Shuang Zhao 12
Example: Evaluating π Shuang Zhao 13
Integral One-dimensional High-dimensional Shuang Zhao 14
Deterministic Integration Quadrature rule: Scales poorly with high dimensionality: Needs n m bins for a m-dimensional problem We have a high-dimensional problem! Shuang Zhao 15
Monte Carlo Integration: Overview Goal: Estimating Idea: Constructing random variable Such that is called an unbiased estimator of But how? Shuang Zhao 16
Monte Carlo Integration Let p() be any probability density function over Γ and X be a random variable with density p Let, then: To estimate : strong law of large numbers Shuang Zhao 17
Monte Carlo Integration Goal: to estimate Pick a probability density function p(x) Generate n independent samples: How? Evaluate for j = 1, 2,, n Return sample mean: Shuang Zhao 18
PDF Sampling A universal method for geniting i.i.d samples from (almost) arbitrary one-dimensional PDFs Given a 1D distribution with PDF f(x), its cumulative density function (CDF) is given by Let, then follows the distribution given by f VP Short Course 2017 Shuang Zhao 19
How to pick density function p()? In theory (Almost) anything In practice: Uniform distributions (almost) always work As long as the domain is bounded Choice of p() greatly affects the effectiveness (i.e., convergence rate) of the resulting estimator Shuang Zhao 20
Monte Carlo Integration Hello, World! Estimating Algorithm: Draw i.i.d x 1, x 2,, x n uniformly from [0, 1) Return Live demo Shuang Zhao 21
Monte Carlo Integration Hello, World! Estimating Shuang Zhao 22
Monte Carlo Integration Goal: to estimate Pick a probability density function p(x) Generate n independent samples: Evaluate for j = 1, 2,, n Return sample mean: Shuang Zhao 23
Central Limit Theorem Let variables with Let be a sequence of i.i.d. random for all i, then Sample mean Estimation error In case of Monte Carlo integration, we have random variable <I> with. It follows that Confidence interval The size of the confidence interval shrinks at a rate of Shuang Zhao 24
Convergence Rate of MC Methods Monte Carlo methods have convergence rates of Evaluating π Evaluating definite integral Shuang Zhao 25
Radiative Transfer VP Short Course 2017 Shuang Zhao 26
Recap: Radiance In Lecture 1, we learnt that radiance L(r, Ω, t) is the central quantity of interest for many biomedical problems For example: defines the fluence at r and time t Shuang Zhao 27
Recap: Radiance Radiance generally depends on tissue geometry & optical properties as well as the source Example: Collimated beam Tissue The rest of this lecture focuses on estimating the radiance field given these information Shuang Zhao 28
Radiative Transfer A physical model describing light propagation in translucent materials based on geometric optics Shuang Zhao 29
Translucent Materials (Materials allowing light to scatter within) Human skin Cloud Milk Shuang Zhao 30
Geometric Optics Describe light as rays Light travels in straight lines in homogeneous media Accurate where the wave characteristics (e.g., diffraction, interference) of light propagation are not prominent Shuang Zhao 31
Stochastic Model Light enters a material and scatters around before eventually leaving or being absorbed X Absorbed Scattered Translucent material (e.g., human tissue) Shuang Zhao 32
Radiative Transfer Equation (RTE) Governs the radiance field L inside volume Boundary condition: radiance L on the boundary Shuang Zhao 33
Radiative Transfer Equation (RTE) Governs the radiance field L inside volume Boundary condition: radiance L on the boundary Steady-state version (i.e., assuming ) First-order integro-differential equation Shuang Zhao 34
Radiative Transfer Equation (RTE) In-scattering Out-scattering & absorption Emission Differential radiance In-scattering Out-scattering & absorption Emission Shuang Zhao 35
Radiative Transfer Equation (RTE) Differential radiance In-scattering Out-scattering & absorption Emission Scattering coefficient: Phase function: Extinction coefficient: Source term:, a probability density for Ω Shuang Zhao 36
Integral Form of the RTE (IRTE) Integro-differential equation Integral equation It is desirable to rewrite the RTE as an integral equation Better suited to the stochastic model Easier to solve numerically Shuang Zhao 37
Integral Form of the RTE (IRTE) Transmittance In-scattering Emission Transmittance Boundary cond. Transmittance: Shuang Zhao 38
Monte Carlo Solution to the Radiative Transfer Equation VP Short Course 2017 Shuang Zhao 39
General Measurements Many biomedical problems requires numerically evaluating integrals of the form f is called the measurement function and is given by the detector Example 1: An internal detector at at this point: measuring the fluence Shuang Zhao 40
General Measurements Example 2: A surface detector measuring irradiance: where θ is the angle between -Ω and the surface normal at r Shuang Zhao 41
General Measurements General measurements can again be estimated using Monte Carlo integration By picking some density p(r, Ω), we have an unbiased estimator Next, we focus on estimating the radiance L, which is the solution of the RTE Shuang Zhao 42
Recap: the IRTE where and Transmittance In-scattering Emission For simpler derivations, we assume the medium to be infinite, causing the second term to vanish Shuang Zhao 43
Solving the IRTE using Monte Carlo where and Consider estimating L(r 0, Ω 0 ) for some fixed r 0 and Ω 0 : Transmittance In-scattering Emission MC integration Shuang Zhao 44
Solving the IRTE using Monte Carlo where and Transmittance In-scattering Emission F 0 contains another integral, so we apply MC integration again: Transmittance In-scattering Emission Shuang Zhao 45
Solving the IRTE using Monte Carlo where and Putting everything together, we get Transmittance In-scattering Emission To obtain L(r 1, Ω 1 ), we simply repeat this whole process starting with r 1 and Ω 1 Shuang Zhao 46
Solving the IRTE using Monte Carlo Transmittance In-scattering Emission Pseudocode: Radiance(r,Ω): draw τ from some pdf p(τ) r 1 = r τ*ω draw Ω 1 from some pdf p(ω 1 ) return T(r 1 r)/p(τ)* ( μ s (r 1 )*p(r 1,Ω 1 Ω)*Radiance(r 1,Ω 1 ) + Q(r 1,Ω) ) Shuang Zhao 47
Solving the IRTE using Monte Carlo Transmittance In-scattering Emission This process effectively constructs a photon path or biography: (r 0, Ω 0 ), (r 1, Ω 1 ), (r 2, Ω 2 ), This construction starts from r 0 on the detector. There exists an adjoint version that starts from the source. Shuang Zhao 48
Solving the IRTE using Monte Carlo Transmittance In-scattering Emission Pseudocode: Radiance(r,Ω): draw τ from some pdf p(τ) Free distance sampling r 1 = r τ*ω draw Ω 1 from some pdf p(ω 1 ) Incident dir. sampling return T(r 1 r 0 )/p(τ)* ( μ s (r 1 )*p(r 1,Ω 1 Ω)*Radiance(r 1,Ω 1 ) + Q(r 1,Ω) ) Shuang Zhao 49
Sampling Incident Direction Transmittance In-scattering Emission Transmittance In-scattering Emission To draw the incident direction, we simply follows the stochastic model by setting p(ω 1 ) based on the phase function at r 1 and Ω 0 This cancels out the phase function term in the nominator Shuang Zhao 50
Sampling Free Distance Transmittance In-scattering Emission To sample the free-flight distance τ, it is desirable to cancel out the transmittance term This can be done by setting, yielding In-scattering Emission Shuang Zhao 51
Sampling Free Distance For homogeneous media, we have and We can draw τ from this exponential distribution using the PDF sampling method: The CDF is Let, then Shuang Zhao 52
Stochastic Model vs. Monte Carlo The Monte Carlo solution to the RTE is equivalent to the stochastic model captures the likelihood for light to collide with some particle in the medium follows the phase function Scattered Shuang Zhao 53 This Biophotonics is NOT 2017 the only solution: other probabilities can be used if necessary
Absorption Weighting In-scattering Emission During the construction of the photon biography, the weight of a photon decreases at each collision due to the scaling factor of is usually called the single-scattering albedo Two interpretations: at each collision, The photon gets absorbed with probability (1 α) The photon s weight scales down with a factor of α Shuang Zhao 54
Analog In-scattering Emission Pseudocode: Radiance(r,Ω): draw τ from r 1 = r τ*ω draw Ω 1 from rad = Q(r 1,Ω)/μ t (r 1 ) if rand() < μ s (r 1 )/μ t (r 1 ): rad += Radiance(r 1,Ω 1 ) return rad Shuang Zhao 55
Discrete Absorption Weighting In-scattering Emission Pseudocode: Radiance(r,Ω): draw τ from r 1 = r τ*ω draw Ω 1 from rad = Q(r 1,Ω)/μ t (r 1 ) rad += μ s (r 1 )/μ t (r 1 )*Radiance(r 1,Ω 1 ) return rad Shuang Zhao 56
Analog vs. DAW Analog is faster DAW offers cleaner results Shuang Zhao 57
Monte Carlo for Inverse Problem Monte Carlo method can also be applied to solve the inverse radiative transfer problem i.e., given some measurement I, need to solve for μ t, μ s, and p The inverse problem is generally more challenging and modeled as an optimization where I 0 is the provided measurement and I is that given by scattering parameters μ t, μ s, and p Also need to determine which norm ( ) to use Shuang Zhao 58
Monte Carlo integration is also used to render photorealistic images Shuang Zhao 59
Colored Explosion [Kutz et al. 2017] Shuang Zhao 60
Soap, Olive Oil, Curacao, and Milk [Gkioulekas et al. 2013] Shuang Zhao 61
Take Home Message Radiative transfer is an accurate model for light propagation in translucent materials when wave effects and not prominent Monte Carlo solution to the RTE provides a gold standard for simulating light propagation in tissue The flexibility of the Monte Carlo framework allows future research toward more efficient estimators Shuang Zhao 62