On 16-Nov-05 Olivia Lau wrote:> Hi,
>
> I'm trying to find a way to take evaluate the Normal CDF over an
> interval and return the result on the log scale. This works, but I
> think it isn't numerically stable:
>
> log(pnorm(a, mean = x, sd = y) - pnorm(b, mean = x, sd = y))
>
> Does anyone know of a single function that does the above? Or knows of
> a way to make it more stable? I'd really appreciate any suggestions!
>
> Thanks,
>
> Olivia
A little more detail might be helpful.
Your formula is simple enough in itself, and you should not be
getting numerical stability problems for reasonable values of
(a-x)/y or (b-x)/y (say in the range -4 to 4). And I assume
you're being careful that a > b!
So for what values of your variables are problems arising?
And how do they manifest themselves?
If it's due to large values of (a-x)/y etc., then possibly
an asymptotic approximation may serve. There are some good
ones around.
Can you tell us a bit more?
Best wishes,
Ted.
--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 16-Nov-05 Time: 20:37:47
------------------------------ XFMail ------------------------------