Cumulative Normal Distribution Function in C/C++

后端 未结 7 2177
走了就别回头了
走了就别回头了 2020-12-07 14:15

I was wondering if there were statistics functions built into math libraries that are part of the standard C++ libraries like cmath. If not, can you guys recommend a good st

相关标签:
7条回答
  • 2020-12-07 14:49

    Theres is no straight function. But since the gaussian error function and its complementary function is related to the normal cumulative distribution function (see here, or here) we can use the implemented c-function erfc (complementary error function):

    double normalCDF(double value)
    {
       return 0.5 * erfc(-value * M_SQRT1_2);
    }
    

    Which considers the relation of erfc(x) = 1-erf(x) with M_SQRT1_2 = √0,5.

    I use it for statistical calculations and it works great. No need for using coefficients.

    0 讨论(0)
提交回复
热议问题