Further Improvements
In this lesson, we will determine what the parameters to Stretch.Distribution should be to get a good result.
We'll cover the following...
In the previous lesson, we were attacking our final problem in computing the expected value of a function f
applied to a set of samples from a distribution p
. We discovered that we could sometimes do a “stretch and shift” of p
, and then run importance sampling on the stretched distribution; that way we are more likely to sample from “black swan” regions, and therefore the estimated expected value is more likely to be accurate.
However, determining what the parameters to Stretch.Distribution
should be to get a good result is not apparent; it seems like we’d want to do what we did: actually, look at the graphs and play around with parameters until we get something that looks right.
Automating the Process to Estimate the Expected Value
It seems like there ought to be a way to automate this process to get an accurate estimate of the expected value. Let’s take a step back and review what exactly it is we need from the helper distribution. Start with the things it must have:
- Obviously it must be a weighted distribution of doubles that we can sample from!
- That means that it must have a weight function that is always non-negative.
- And the area under its weight function must be finite, though not necessarily .
And then the things we want:
- The support of the helper distribution does not have to be exactly support of the
p
, but it’s nice if it is. - The helper’s weight function should be large in ranges where
f(x) * p.Weight(x)
bounds a large area, positive or negative. - And conversely, it’s helpful if the weight function is small in areas where the area is small.
Well, where is the area likely to be large? Precisely in the places where Abs(f(x) * p.Weight(x))
is large. Where is it likely to be small? Where that quantity is small… so…
why don’t we use that as the weight function for the helper distribution?
As we noted before in this course, all of these techniques ...