I'm trying to calculate $\prod_k{p_k}$ where $p_k$ are (potentially) very high probabilities of independent, zero-mean, standard normal random variables and $k>100$. However, I'm running into numerical problems using MATLAB (although the same problem occurs in Python/Scipy). Let's say $x=30$, then
normcdf(x)
returns 1, which is not precise. However, if I use normcdf(-x)
(or normcdf(x,'upper')
) instead, I get a value of 4.906713927148764e-198. I was hoping that I could then take 1 minus this value to get a more accurate probability. Unfortunately, the result gets rounded, as soon as I apply the subtraction:
>> normcdf(-x)
ans =
4.906713927148764e-198
>> 1-(1-normcdf(-x))
ans =
0
Is there any way to work around this issue?
log1p(-normcdf(-x))
, which, in this case, returns exactly-normcdf(-30)
.eps(1)
is much larger thannormcdf(-30)
so you'll never be able to subtract it in floating point. $\endgroup$