C + + calculates normal distribution integrals

Source: Internet
Author: User

It is very convenient to calculate normal distribution integrals in python,c# and other languages.

Referring to C + +, many people will find this language very stupid, if not for the sake of efficiency, very few people will write programs in C + +. In fact, recently found that C + + has many well-packaged libraries, such as matrix Computing has Eigen library.

Today I want to compute a standard normal distribution of integrals in C + +. Looked up a lot of things, including boost and so on.

Finally found that c++11 can be directly computed Erf (x), a little change can be calculated Gaussian function integral. Introduction of ERF in Https://en.wikipedia.org/wiki/Error_function

The specific code is as follows:

Const double m_sqrt1_2 = sqrt (0.5);
Double Normalcfd (Double value)
{
Return 0.5 * ERFC (-value * m_sqrt1_2);
}

Main reference: Https://stackoverflow.com/questions/2328258/cumulative-normal-distribution-function-in-c-c

C + + calculates normal distribution integrals

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.