1

InverseCDF works fine with the normal distribution quite far out on the right tail, but eventually I am getting an $\infty$ error. Thus

N[InverseCDF[NormalDistribution[], 1 - 9*10^-15]]

gives

7.66416

but

N[InverseCDF[NormalDistribution[], 1 - 9.1*10^-15]]

gives

How can I avoid getting the infinity error?

  • 3
    You should use rational numbers (9110^-16) rather than machine precision numbers in this case: `N[InverseCDF[NormalDistribution[], 1 - 9110^-16]]` gives 7.66275. And don't be surprised if this question is closed because this is a common issue. See https://reference.wolfram.com/language/tutorial/Numbers.html#21155 and https://mathematica.stackexchange.com/questions/118797/machine-precision-and-arbitrary-precision. – JimB Apr 15 '22 at 15:54

1 Answers1

5

A series expansion helps to stabilize the calculation:

a[y_] = Assuming[0 < y < 1,
  FullSimplify[Normal[Series[InverseCDF[NormalDistribution[], 1-y], {y, 0, 1}]]]]
(*    Sqrt[-2*Log[y] - Log[-2*π*Log[2*π*y^2]]]    *)

Evaluation is now very stable even for small values of $y$:

a[9.1*10^-15]
(*    7.66047    *)

a[3.7*10^-81] (* 19.0435 *)

Roman
  • 47,322
  • 2
  • 55
  • 121