哪个java库计算累积标准正态分布函数?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/442758/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 14:41:28  来源:igfitidea点击:

Which java-library computes the cumulative standard normal distribution function?

javastatisticsprobabilitycomputation

提问by Mnementh

For a project I have a specification with formulas, I have to implement. In these formulas a cumulative standard normal distribution function exists, that takes a float and outputs a probability. The function is symbolized by a Φ. Exists a Java-library, that computes this function?

对于我有公式规范的项目,我必须实施。在这些公式中,存在累积标准正态分布函数,它采用浮点数并输出概率。该函数用 Φ 表示。是否存在计算此函数的 Java 库?

采纳答案by Mnementh

A co-worker suggested colt, as he used it before. This functionhas exactly the result as the example in the reference document.

一位同事建议使用colt,因为他以前使用过它。此函数的结果与参考文档中的示例完全相同。

回答by Yuval Adam

Apache Commons - Mathhas what you are looking for.

Apache Commons - Math有你想要的。

More specifically, check out the NormalDistributionclass.

更具体地说,查看NormalDistribution课程。

回答by Ryu

SuanShu, a Java numerical analysis library, computes the normal distribution and many other statistical distributions.

SuanShu 是一个 Java 数值分析库,用于计算正态分布和许多其他统计分布。

回答by Erk

If you want the exact code, this one seems to be the same function used in OpenOffice Calc (I've made some changes for it to work in java):

如果您想要确切的代码,这似乎与 OpenOffice Calc 中使用的函数相同(我已经对其进行了一些更改以使其在 Java 中工作):

// returns the cumulative normal distribution function (CNDF)
// for a standard normal: N(0,1)
double CNDF(double x)
{
    int neg = (x < 0d) ? 1 : 0;
    if ( neg == 1) 
        x *= -1d;

    double k = (1d / ( 1d + 0.2316419 * x));
    double y = (((( 1.330274429 * k - 1.821255978) * k + 1.781477937) *
                   k - 0.356563782) * k + 0.319381530) * k;
    y = 1.0 - 0.398942280401 * Math.exp(-0.5 * x * x) * y;

    return (1d - neg) * y + neg * (1d - y);
}

Found it here: http://www.codeproject.com/Messages/2622967/Re-NORMSDIST-function.aspx

在这里找到:http: //www.codeproject.com/Messages/2622967/Re-NORMSDIST-function.aspx

回答by daveagp

You could use the power series formula, which only takes up about 10 lines of code... see for example http://introcs.cs.princeton.edu/java/22library/Gaussian.java.html(the function Phi)

你可以使用幂级数公式,它只占用大约 10 行代码......参见例如http://introcs.cs.princeton.edu/java/22library/Gaussian.java.html(函数Phi