Gamma_inv returns an error if the random number passed to it is higher than roughly 0.96. This happens in both Excel and with VBA. I am running a Monte Carlo, and this only happens 10 or so times in over 40,000 runs. Here is how I am using it. alpha and beta are always >0. If "gammatrunc"= 1, I get the errors. If I set it to 0.95, I get no errors:
alpha = B * B * bsy2 ^ -2
beta = bsy2 * bsy2 / B
rand = Rnd * gammatrunc
B = WorksheetFunction.GAMMA_Inv(rand, alpha, beta)
The errors look like this:
I'd appreciate any thoughts on why this is happening.
Thanks