Monte Carlo Integration via Ray Casting

81 Views Asked by At

Let's suppose we have a 2D line segment $S$ at $y=0$ and extending from $x=-h$ to $x=+h$. We define a function $f(x)=1$ for every point $x$ of $S$.

We wish to integrate $f$ over $S$ with Monte Carlo integration using a specific procedure (designed to work with an unknown, arbitrary curve instead of a line segment).

First we set a few things up:

  1. We start by choosing an arbitrary line $L$ containing the origin point $\mathbf 0$, and we call $L^\perp$ the line orthogonal to $L$ that also contains $\mathbf 0$.
  2. We define a segment $R=[-r,+r]$ on $L^\perp$, centered around $\mathbf 0$ ($r>=h$).

We now perform the integration:

  1. We take a uniform random point $x$ on $R$ with probability $P(x)=1/(2 r)$, and we consider the line $A$ orthogonal to $L^\perp$ and intersecting $L^\perp$ at $x$.

  2. The line $A$ intersects the line $y=0$ at an abscissa $t=x \cos \theta$ where $\theta$ is the angle between $L$ and the line $x=0$.

  3. If $t$ is on the segment $[-h,+h]$ then the contribution of this sample is ${f(t)\over P(t)}={1\over 1/(2 r)}{1\over|\cos\theta|}$ where the $1\over|\cos\theta|$ factor is due to the change of measure.

This procedure allows us to find the integral of $f$ over $x$ (which is equal to $2 h$ in this case), regardless of the choice of $L$ and $r$.

Now, let's pretend we know of two lines, $L_1$ and $L_2$, which we believe are good candidates for the choice of $L$, i.e. they would lead to lower variance. Moreover, we would like to pick $L_1$ with probability $P_{L_1}$ and $L_2$ with probability $P_{L_2}$, with $P_{L_1}+P_{L_2}=1$.

What would be the proper way to use the above procedure with two different lines $L_1$ and $L_2$ and combine the results to get a better estimate of the integral of $f$ over S than with a single line?

Edit: If anything above seems suspicious or plain wrong, thanks for pointing it out!

Edit: Here is an illustration of the setup: enter image description here