Conversation
src/distribution/gamma.rs
Outdated
| } | ||
|
|
||
| fn inverse_cdf(&self, p: f64) -> f64 { | ||
| const MAX_ITERS: (u16, u16) = (8, 4); |
There was a problem hiding this comment.
Is there a special reason for defining the number of iterations like this? It's probably more natural to just
for _ in 0..8 {since the complexity is pretty low
There was a problem hiding this comment.
I thought,
8 and 4 sound like nice numbers, what does that give me. 8 bisection is 2 digits in
$p$ and NR is quadratic convergence, so 4 gives 16 digits, lucky me. Hmm, it's helpful to name things, soconstit is.
Then I thought,
I don't want to name two close but separate things, tuple it is.
I.e. I would be fine changing it to literal.
However, since my attention is on it, I think I might instead do the initial bracketing a little differently and try some math to back up the number of iterations I select.
There was a problem hiding this comment.
I see. It's not a problem either way, I just wanted to know why you used that const tuple there.
9041a98 to
f4a85d1
Compare
…nverse_cdf uses bisection prior to NR search
f4a85d1 to
cc96883
Compare
|
Since it works and I've not already reviewed how to make it "better" I don't think I will for now. If we get a handle on provided or emitting precisions then I think property testing shrinking could use some of that precision information to help find larger parameter space with correct behavior. |
Don't think there's a closed form expression for inverting the CDF, so this improves on the bisection approach with a few iterations of Newton-Raphson since we have
pdfalso adds tests