将浮点精度添加到qnorm/pnorm吗? [英] Adding floating point precision to qnorm/pnorm?

查看:103
本文介绍了将浮点精度添加到qnorm/pnorm吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从当前水平计算qnorm/pnorm时,我想增加浮点数限制,例如:

x <- pnorm(10) # 1
qnorm(x) # Inf
qnorm(.9999999999999999444) # The highst limit I've found that still return a <<Inf number

是否可以(在合理的时间内)做到?如果可以,怎么办?

解决方案

如果参数位于右上角,则应该可以通过计算1-p来获得更好的精度.像这样:

> x = pnorm(10, lower.tail=F)
> qnorm(x, lower.tail=F)
10

我希望(尽管我不确定),pnorm()函数引用的是C或Fortran例程,该例程停留在硬件支持的任何浮点大小上.重新安排您的问题可能更好,这样就不需要精确了.

然后,如果要处理非常大的z值,则可以使用log.p = T:

> qnorm(pnorm(100, low=F, log=T), low=F, log=T)
100

对不起,这不是您要找的东西.但是我认为它将具有更大的可扩展性-pnorm在高z值(毕竟是e ^(-x ^ 2))下如此快地命中1,即使您添加更多位,它们也会很快用完.

I would be interested to increase the floating point limit for when calculating qnorm/pnorm from their current level, for example:

x <- pnorm(10) # 1
qnorm(x) # Inf
qnorm(.9999999999999999444) # The highst limit I've found that still return a <<Inf number

Is that (under a reasonable amount of time) possible to do? If so, how?

解决方案

If the argument is way in the upper tail, you should be able to get better precision by calculating 1-p. Like this:

> x = pnorm(10, lower.tail=F)
> qnorm(x, lower.tail=F)
10

I would expect (though I don't know for sure) that the pnorm() function is referring to a C or Fortran routine that is stuck on whatever floating point size the hardware supports. Probably better to rearrange your problem so the precision isn't needed.

Then, if you're dealing with really really big z-values, you can use log.p=T:

> qnorm(pnorm(100, low=F, log=T), low=F, log=T)
100

Sorry this isn't exactly what you're looking for. But I think it will be more scalable -- pnorm hits 1 so rapidly at high z-values (it is e^(-x^2), after all) that even if you add more bits they will run out fast.

这篇关于将浮点精度添加到qnorm/pnorm吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆