-
Notifications
You must be signed in to change notification settings - Fork 3
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
Check self-consistency of base measure sampler and logdensity #13
Comments
@cscherrer it might be a good idea to include something like this in the test function for measures in MeasuresBase. |
The logic of this is based on
Using similar logic, we have
|
Great idea! (2) will miss in most cases, since you can't sample from Lebesgue measure. But we could maybe sample from a Cauchy and use log-density with respect to that. One question I'm not sure of is reliability. The PSIS paper has some discussion about this, but I'll have to have another look to recall details. |
For easy reference later, from the PSIS paper:
|
Yeah, (1) has the same problem. But if we have an automated way to compute density wrt a different base measure (this is what 3-arg
Good point. If necessary, we could use PSIS to help with this, and IIRC (and as the quote indicates), this would also give us a way to diagnose when the test failed because importance sampling just didn't work. But the first think we could try is the simple truncation correction they give in eq (3). This may not be very useful for MeasureTheory.jl itself, since it currently uses Distributions for most samplers, but I'm at least going to add a test function for this to this repo, since it successfully diagnosed problems with almost all of my |
It needs more work, I wouldn't trust it yet.
👍
Great to hear! It's nice that it's relatively cheap to try, and if you hit instability it will be pretty obvious - tests will fail occasionally, which should be easy to adjust for if/when it comes up. |
For any measure
μ
that has the following properties:ν
is a probability measureν
μ
,we can use importance sampling to check the self-consistency of the log density and sampling.
To do so, we draw
N
times fromν
and then average thedensity
ofμ
wrtν
over the sample. For a correctly normalized distribution, the result should be close to 1. Failure indicates that the either the sampler from theν
is incorrectly implemented, or the logdensity ofμ
is.We can do this with a function like the following, which demonstrates that our
logdensity
implementation forVonMisesFisher{Stiefel}
may be incorrectly normalized:The text was updated successfully, but these errors were encountered: