RayTracing / raytracing.github.io

Main Web Site (Online Books)
https://raytracing.github.io/
Creative Commons Zero v1.0 Universal
8.22k stars 828 forks source link

Book 3.3.1: Not very clear what we are doing #1530

Open dimitry-ishenko opened 3 months ago

dimitry-ishenko commented 3 months ago

Chapter 3, at the very beginning, states that we can use Monte-Carlo method to compute area of a circle with radius 1.

Chapter 3.1 tries to expound on that, but does it in a somewhat haphazard way. There are several proofs that tie the expected value to the Monte-Carlo method and the area under the curve (AUC), but there is no clear explanation as to why we need the expected value and how it all ties together.

My understanding of the chapter is this:

What we are trying to say is that we can use Monte-Carlo method to compute AUC of an arbitrary function using the expected value.

First, we can estimate the expected value of a function using Monte-Carlo method:

$$ E[f(x') | a \leq x' \leq b] \approx \frac 1 N \sum_{i=0}^{N-1} f(x_i) $$

At the same time, we've proven that:

$$ E[f(x') | a \leq x' \leq b] = \frac{1}{b - a} \int_{a}^{b} f(x) dx $$

And, since we know that:

$$ area(f(x), a, b) = \int_{a}^{b} f(x) dx $$

we can use Monte-Carlo method to estimate AUC of an arbitrary function $f$:

$$ area(f(x), a, b) = (b - a) \cdot E[f(x') | a \leq x' \leq b] $$

$$ area(f(x), a, b) \approx \frac{b - a}{N} \sum_{i=0}^{N-1} f(x_i) $$

QED

hollasch commented 3 months ago

Moving into the v4.0.0 milestone for consideration. We may or may not punt this for the actual v4.0.0 release, depending on our progress.