为什么在1E-16之后,apache数学中的尾部概率下降到零? [英] Why does tail probability in apache math drop to zero after 1E-16?

查看:155
本文介绍了为什么在1E-16之后,apache数学中的尾部概率下降到零?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Apache Math 3.4(和3.3),java 1.8.0_25

Apache Math 3.4 (and 3.3), java 1.8.0_25

import org.apache.commons.math3.distribution.ChiSquaredDistribution;
ChiSquaredDistribution chisq = new ChiSquaredDistribution(23)
System.out.println(1.0 - chisq.cumulativeProbability(130) //  1.1102230246251565E-16
System.out.println(1.0 - chisq.cumulativeProbability(131) //  0.0

为什么Apache Math在第二个调用中返回0.0?一些统计资料库(Excel,但不是R)的返回值的尾部概率远小于1E-16.

Why does Apache Math return 0.0 in the second call? Some stat libraries (Excel, but not R) do return values that are much smaller than 1E-16 for the tail probabilities.

其他在下面的评论中,Robert提供了一种直接的方法,可以使用Apache数学库中的另一个函数(regularizedGammaQ)计算卡方尾概率.

Additional In the comments below, Robert provides a direct way of calculating chi square tail probabilities using another function from Apache math library (regularizedGammaQ) that does not have this precision problem.

ChiSquaredDistribution Javadoc

推荐答案

请注意,可以从1.0中减去得出小于1.0的最小值的最小值约为1e-16;您可以直接验证.也许您应该打印出chisq.cumulativeProbability(131)本身.我不知道它是否正确,但是无论如何不要让它从1.0中减去来混淆这个问题.

Note that the smallest value which can be subtracted from 1.0 to yield something less than 1.0 is approximately 1e-16; you can verify this directly. Maybe you should print out chisq.cumulativeProbability(131) itself. I don't know if it's correct but in any case let's not confuse the issue by subtracting it from 1.0.

这篇关于为什么在1E-16之后,apache数学中的尾部概率下降到零?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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