向 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
在合理的时间内)是否可以做?如果是这样,怎么办?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果参数位于上尾部,您应该能够通过计算 1-p 获得更好的精度。像这样:
我希望(尽管我不确定)pnorm() 函数引用的是 C 或 Fortran 例程,该例程卡在硬件支持的任何浮点大小上。可能最好重新安排你的问题,这样就不需要精度了。
然后,如果您正在处理非常非常大的 z 值,您可以使用 log.p=T:
抱歉,这不正是您正在寻找的。但我认为它会更具可扩展性——pnorm 在高 z 值时如此快速地达到 1(毕竟是 e^(-x^2)),即使您添加更多位,它们也会很快耗尽。
If the argument is way in the upper tail, you should be able to get better precision by calculating 1-p. Like this:
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:
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.