-
Notifications
You must be signed in to change notification settings - Fork 868
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Book 3.3.7: Magic transformation #1534
Comments
My gut feeling on these two points is this: Since, And so, dividing all samples by |
I was able to tie in points 1 and 2 above. Assuming point 2 is correct, we can rewrite our formula for estimating area of function How does this tie in with the earlier formula from chapter 3.1? Well, in chapter 3.1 we've used an implicit constant PDF Now, if we re-arrange the formula (2) above we get: which is the same as formula (1). QED The only open question remains is, what magic did we use to come up with formula (1)? In other words, why is up/down-weighting by the PDF yields the correct result? |
Found this wikipedia artice—Monte Carlo integration—which confirms that formula (1) above is the right way of integrating any arbitrary function One important note: to get accurate results, samples |
In listing 13 we transform our code to compute integral of$x^2$ using explicit inverse CDF ($f$ ) and PDF ($p$ ) functions.
(Note: Using$f$ to denote $CDF^{-1}$ is very unfortunate, since we also use $f$ to denote arbitrary functions in several places in the book.)
After the listing there are a few "controversial" statements, which are glossed over and are not explained:
"We were previously multiplying the average over the interval (
sum / N
) times the length of the interval (b - a
) to arrive at the final answer. Here, we don't need to multiply by the interval length—that is, we no longer need to multiply the averageby 2."
What'd just happen? One doesn't simply decide that "we don't need to multiply by the interval length" and magically arrive at the right result. There must be some logic (math) behind it, which is glossed over.
"To remove this bias, we need to down-weight where we sample more frequently, and to up-weight where we sample less frequently. ... This is why we divide
x*x
bypdf(x)
."I can intuitively understand that since we are sampling more frequently in the areas of high PDF, we want to down-weight those samples to avoid the bias (and vice versa). But, how/why did we decide that dividing by PDF is just the right amount?
The text was updated successfully, but these errors were encountered: