Open bonStats opened 5 years ago
Been checking this out in R
... I think this is better:
q <- 1 - sqrt( (4 / (y * mu)) + 1 )
q[q < 0] <- 0
x <- mu * (1 + (mu / 2) * ( y * q ) )
@bonStats Thanks. Sure, issue PR, I'll be happy to look at it.
Great package, thanks for publishing. I think I have found problem in the
rng_wald
for very largelambda
. I am getting zero and negative values fromrwald
, for example tryrwald(n=100, lambda = 1, mu = 1e20)
.Line 72 and 73 of
wald-distribution.cpp
should be using something like Horner's method for numerical stability. I think the following should be acceptable:versus the original
I can issue a pull request late next week if that helps. Might need to factor out
lambda
too.