0
> pnorm(-37)
[1] 5.725571e-300

> pnorm(-37.5)
[1] 4.605353e-308

Now when I decrease the number a tad bit more, I get a 0

> pnorm(-37.6)
[1] 0

Would it be possible to have R display an even smaller number? Ideally, it would be great to get a numerical value for pnorm(-39) and even pnorm(-125).

Adrian
  • 9,229
  • 24
  • 74
  • 132

1 Answers1

1

As the comments point out you can convert these to log scale by using the log.p= argument. This, however, gives it to you in base e, and if you want it to be in base 10 like the examples you gave above, you could get the output you're looking for like this:

x <- pnorm(-39, log.p = T)
x * log10(exp(1))
# -332.2714

x <- pnorm(-125, log.p = T)
x * log10(exp(1))
# -3395.422

Which you can interpret as the power in your examples in the question.

Examples


Some examples showing this works:

x <- pnorm(-35, log.p = T)
x * log10(exp(1))
# -267.9489

pnorm(-35)
# 1.124911e-268

x <- pnorm(-19, log.p = T)
x * log10(exp(1))
# -80.06919

pnorm(-19)
# 8.527224e-81

Exact Answer


An example to show the actual number:

x <- pnorm(-37.5, log.p = T)
x * log10(exp(1))
# -307.3367

pnorm(-37.5)
# 4.605353e-308
10^-307.3367
# 4.605746e-308

which is only off slightly due to rounding (plug in the actual number from the code to get exact answer).

Of course for bigger numbers you'll have to leave it in exponent form since R will still give you 0.

ex: 10^-332.2714

If you wanted what R would give you if it didn't round very small numbers to 0, you could separate the exponent apart. For example 10^-2 = 10^(-1-1), or in our case, 10^-2.2 = 10^-(2 + 0.2). So following these steps on an answer we can double check with pnorm():

x <- pnorm(-35, log.p = T)
x * log10(exp(1))
# -267.9489
pnorm(-35)
# 1.124911e-268

10^-(267 + .9489)
#1.124864e-268

10^-0.9489 * 10^-267
#1.124864e-268

0.1124864 * 10^-267
#1.124864e-268

0.1124864e-267
#1.124864e-268

So walking through on an example where R gives 0:

x <- pnorm(-125, log.p = T)
x * log10(exp(1))

10^-.422 * 10^-3395
0.3784426e-3395

So the answer R would give if it didn't stop and round to 0, would be: 0.3784426e-3395

Why it works


This works because the output you get is x = exp(pnorm(q, log.p = T)). So to convert it to base 10, you can just use log rules:

log10(exp(x)) = x * log10(exp(1))
brinyprawn
  • 168
  • 6