1
我在Java中实现MATLAB的gammainc时遇到问题。在java中实现gamma不完整
我试过一部分一部分。我使用这些函数使用兰克泽斯逼近,我在网络上得到了解决Γ(一):
private static double logGamma(double x) {
double tmp = (x - 0.5) * Math.log(x + 4.5) - (x + 4.5);
double ser = 1.0 + 76.18009173 /(x + 0) - 86.50532033 /(x + 1)
+ 24.01409822 /(x + 2) - 1.231739516 /(x + 3)
+ 0.00120858003/(x + 4) - 0.00000536382/(x + 5);
return tmp + Math.log(ser * Math.sqrt(2 * Math.PI));
}
private static double gamma(double x) { return Math.exp(logGamma(x)); }
然后我用辛普森规则解决的组成部分,那么我将它们结合在一起做gammainc但我得到的输出是不合理的。
整体部分也可以看作是lower incomplete gamma function。
我在寻求更好的解决方案。
谢谢你的建议。也许我对整体部分的近似导致了我的麻烦。我不知道我是否得到了一个很好的近似值,因为我没有一个应用程序来检查它。再次感谢你 – 2012-01-02 23:22:36