-
Notifications
You must be signed in to change notification settings - Fork 429
Implement ExpGamma sampler (draft) #1958
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
base: master
Are you sure you want to change the base?
Conversation
Co-Authored-By: David Widmann <devmotion@users.noreply.github.com>
Co-Authored-By: chelate <42802644+chelate@users.noreply.github.com>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1958 +/- ##
==========================================
- Coverage 86.20% 85.97% -0.23%
==========================================
Files 146 147 +1
Lines 8769 8792 +23
==========================================
Hits 7559 7559
- Misses 1210 1233 +23 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
I found an issue in ExpGammaIPSampler that is beyond my understanding. The values it generates are too high. If you undo the log on them, the output has a low bound of 1 instead of 0. I don't think it's a sign issue. julia> rand(rng, GammaIPSampler(Gamma(0.9)), 10)
10-element Vector{Float64}:
0.2135985770580691
1.137650455835034
1.2565944033941983
0.656188185739729
0.4203566698386437
1.66687553573059
0.2053545534917769
0.41111662368149415
0.14513700772532737
0.6549826409710889
julia> exp.(rand(rng, ExpGammaIPSampler(Gamma(0.9)), 10))
10-element Vector{Float64}:
2.051378946898306
1.0193261057366838
2.0454369373226133
1.1704569694617193
1.363270090050132
3.747017831243905
2.1354060996412194
1.0657728289135096
1.173677653737439
1.0294127958057897 and julia> rand(rng, GammaIPSampler(Gamma(0.01)), 10)
10-element Vector{Float64}:
1.836714536149393e-57
1.5105073011994874e-50
3.537147232822205e-36
1.2547571475373618e-32
5.885231757348809e-38
2.9054960529000983e-34
1.2110309289241029e-6
1.4231361276813385e-101
2.393431274684707e-27
4.809894203977362e-38
julia> exp.(rand(rng, ExpGammaIPSampler(Gamma(0.01)), 10))
10-element Vector{Float64}:
1.0207709469175534
1.0000000000000002
1.0000000000000946
1.0
1.0
1.0
1.0
1.0000000000087867
1.0
1.000000000000009 The code looks mathematically correct to me. It's about 2x faster than ExpGammaSSSampler, but ExpGammaSSSampler returns values in the expected range while ExpGammaIPSampler is broken. |
I found the issue; one of the ExpGammaIPSampler methods was actually returning a GammaIPSampler. |
After correcting that, I have done some basic testing. This means I've checked for rates of non-finite values and duplicates. I have not checked past that. If something "works", it means it's generating unique finite values. I have found that:
I'll make some charts later. Note that I have NOT looked into how "accurate" the numbers generated have been yet. It is very much possible that the Log Inverse Power sampler is generating nonsense at some point. |
Thanks for the work and documentation! I am able to look into this in July, but I will probably need lots of help because I am not much of a coder. That said, I am really really annoyed by the lack of a ExpGamma sampler and will do my best. Personally, I don't think what happens below 1e-308 is really important, and the IPS sample seems to "dominate" to use the statistical parlance. I mean with gamma occasionally giving zeros at like 1e-3 or something, Id hardly worry about something that is slightly suboptimal 300 orders of magnitude later, right? |
As discussed in #1886 , here is a branch with only the ExpGamma additions I made. This is hopefully of use to @chelate.
Potential TODOs: