The lecturer introduces Monte Carlo integration as a simple, sample-based method to approximate definite integrals, claiming it removes the need to evaluate integrals analytically. He gives historical context (Stanislaw Ulam and the Manhattan Project) and contrasts two variants—hit-and-miss and sample-mean—while presenting a visual "recipe": enclose the function in a known box, throw random points, count points below the curve, and use the ratio to estimate area. As an illustrative example he shows the hit-and-miss method to approximate π by sampling inside the unit square and counting points inside a quarter-circle, and notes the approach trivially generalizes to higher-dimensional integrals (relevant to rendering).
Chapters
Let's go to Monte Carlo integration. I promise you something. If you learn what Monte Carlo integration is, you will never ever in your life will have to evaluate any more integrals. Never. I promise to you. I give you my word. And this is a simple method to approximate integrals. And basically what we are looking for is we would like to integrate the function and we can take samples of this function. What does it mean? We will check it out in a second. So we will take some samples of this function and we would like to reconstruct the integral of it. If we do this, this is what's called Monte Carlo integration. And this was founded during the second World war by Stanislaw Ulam and his co workers during the Manhattan Project. So this was the atomic bomb project. They had unbelievably difficult integrals to solve. And they had to came up with a numerical solution in order to at least approximate them. So this is what they came up with. There's two different kinds of of Monte Carlo integration. The keys I have this function F of X. And I would like to integrate this from A to B. So this is a definite integral. What I can do is hit or miss Monte Carlo or sample mean. Monte Carlo 99.9% of the case. We use the sample mean, but just for the intuition and to visualize what is going on. I will show you the hit and miss as well. And at all times we can choose how to take samples from this function. So let's take a look at this. This is the recipe like for wonderful Wiener schnitzel. This is the recipe for Monte Carlo integration. You draw this function that you have on a paper. You close it in a box that you know the size of and let the size of the box be a. You throw lots of random points on this paper. And for every single point you have, you determine if it is above or below this function. And then you have a magical formula. You use this formula and you will get the integral. The more points you have on the paper, the better. So I compute the ratio of hits, the points below the curve, the function compared to all the samples that I have. How does it look like this? Looks more or less like this. So this immediately gives you the intuition that the reds are above the function, the blues are below the function. So I would like to know the ratio of blues to all samples. Because this gives you exactly what integrals mean. Integrals mean the area below this curve. So get this. If I would be on a summer holiday, I could have some beers and get a crazy Idea that I would go on top of my house and imagine that I have a pool of water and I would start throwing beach balls in this pool. And after doing this for long enough, I could approximate the value of PI. Sounds like black magic, right? Provided that the poles are small enough and I am patient enough, then this can happen. Okay, what is the recipe? Let's go through it. Let's draw a unit square somewhere. So the area of this square is going to be one. Lets draw a quarter of a unit circle inside this box. And this is also of unit radius. Now we start throwing these points. We compute the ratio, what is inside and how much is outside. We multiply the result by four and then we get PI. So let me say this again. We multiply the results by four and we get PI. Now how is this? I mean, this doesn't sound like that it makes any sense, but this is black magic and this works. Let's take a closer look at why this works. So I would like to compute the integral. The integral would be below this function. This is the one corner of a sphere of a circle. Sorry. And what is the area of the sphere? R squared times PI? Well, r is 1, so it's PI over 4. So what we are essentially approximating here is PI over 4. So I have this. When I solve this integral, what I get as a result is PI over 4. Well, what do I need to do with this in order to get PI multiplied by louder? 4. Yes, exactly. So Shadow and Cooper will be proud for all of us. Physicists do a lot of this. Excellent. Yes. What if you have a surface, not a 2D? This also works for multidimensional functions. And you will actually compute such a thing in the next assignment. And it's going to be absolutely trivial. So this trivially generalizes for arbitrary dimensions. Well, it better be, because the rendering equation is infinite dimensional, so it has to take care of high dimensional functions somehow.