 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 be loaded anymore integrals. Never, I promise to you, I give you my word. This is a simple method to approach that integrals. 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. We will take samples of this function and we would like to reconstruct the integral. If we do this, this is what is called Monte Carlo integration. This was founded during the Second World War by Stanislav Lom and his co-workers during the Manhattan Project. This was the Antonin von project. They had unbelievably difficult integrals to solve. They had to come up with a numerical solution in order to at least approximate. This is what they came up with. There are two different kinds of Monte Carlo integration, the keys. I have this function f of x and I would like to integrate this for me to be. This is a definite integral. What I can do is hit our 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 hidden miss as well. We can see how we can take samples of this function. Let's take a look at this. This is the recipe for a wonderful Viennese Nizzo. 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 vague. You throw lots of random points on this paper and for every single point you have in determine if it is above or below this function. 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. I compute the ratio of hits the points below the curve of the function compared to all the samples that I have. How does it look like? This looks more or less like this. This immediately gives you the intuition that the reds are above the function. The blues are below the function. I would like to know the ratio of blues to all samples because this gives you exactly what the integrals mean, the area below this curve. 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. I would start throwing beach balls in this pool and after doing this for long enough, I could approximate the value of pi. It sounds like black magic. Provided that the balls are small enough and I am patient enough that this can happen. What is the recipe? Let's go through it. Let's draw a unit square somewhere. The area of this square is going to be one. Let's draw a quarter of a unit circle inside this box. 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. Now how is this? This doesn't sound like that it makes any sense. This is black magic and this works. Let's take a closer look at why this works. I would like to compute the integral. The integral would be below this function. This is the one quarter of a sphere of a circle. What is the area of the sphere? R square times pi. R is one. It's pi over four. What we are approximately approximating here is pi over four. When I solve this integral, what I get is a result is pi over four. What we need to do with this in order to get pi multiplied by lambda. Shadow Cooper would be proud for all of us. This is due to a lot of this. What if we have a surface not a 2D? This also works for multidimensional functions. You will actually compute such a thing in the next assignment. It will be absolutely trivial. This is trivial. It is better because the rendering equation is infinite dimensional. It has to take care of high-dimensional functions somehow.