# Monte Carlo Integration

This topic is 2777 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I understand the basic Monte Carlo Integration technique ok. Its basicaly just the riemann sum

But I get a little confused when they start adding importance sampling, by dividing by the PDF.

From what I gather, when using the importance sampling technique above, f() must sample from the same distribution as p(). What happens if the probaility for some Xi was a very very samll number?, if it were to occur then you would be dividing by that and get a very large number accumilated into the sum.

One example Ive seen is the cosine weighted hemisphere distribution. Where when used for producing directions, would give a higher probability of sampling a direction closer to the normal direction. The pdf for the CosineWeightedHemisphere distribution function gives smaller values for directions that have a lower cos(theta) value. But doesnt this mean that when you divided by that pdf, the smaller the cos(theta) value, the more it contributes, due to the denominator getting smaller? i thought the idea was to get directions closer to the normal contributing more?

##### Share on other sites
Hmmm... It's not really a Riemann sum: It's just the average of a sample, as an estimator of the true average of a probability distribution.

Importance sampling is a method that allows you to concentrate more effort in some part of the space (hopefully in the parts that matter more for the computation). For instance, if you want to compute the average of some function on the interval [0,1] and you know that the values in [0,1/2] are pretty much all the same, but there is a lot of variation in [1/2,1], you may want to use 10 samples in [0,1/2] but 1000 samples in [1/2,1]. Of course the individual contribution of a sample in the first half will be 100 times larger than that of a sample in the second half. If you think of it as sampling by using a distribution that has a density that is 100 times larger in [1/2,1] than in [0,1/2], you'll see why they divide by the probability density.

##### Share on other sites

i thought the idea was to get directions closer to the normal contributing more?

Nope! You want each region to contribute the same as it would have with uniform sampling. But now you expect different numbers of samples from different regions, so you need to compensate for that. If you expect, e.g., 10x the number of samples from one region, then you weight each by 1/10-th as much to compensate.

You could imagine a situation in which you had no idea what the probability distribution P you were sampling from was, and you just chose to count, for each Xi, how many samples you got at Xi. Then it wouldn't be terribly surprising if, to make your estimates, you just divided the sums-of-values you'd gotten by these numbers; that's just how you're used to computing averages. This is the same as what you're doing here, except here, instead of using sample counts -- an empirical measurement of what the probability distribution is -- you're using the actual probability distribution itself.

What happens if the probaility for some Xi was a very very samll number?

Then you expect very few samples from that region, each weighted by a heck of a lot -- by 1/P(Xi). A consequence is that any noise will also be weighted by 1/P(Xi), so your estimate of this region will be relatively inaccurate. What this has bought you, for a given total number of samples, is more samples in other regions, whose values you'll now know more accurately. You're trading accuracy in some regions for accuracy in others.

1. 1
2. 2
3. 3
Rutin
15
4. 4
5. 5

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633725
• Total Posts
3013567
×