Calculate the CDF of Poisson distribution with Boost C + + Library

Source: Internet
Author: User

The cumulative distribution function (CDF) of Poisson distribution can be easily calculated by R function Ppois () or octave /matlab function Poisspdf (). However, it isn't a easy thing to deal with statistics with C + + from scratch.

Today I found a very powerful C + + mathematical library (actually not limited to math), boost. Unfortunately, it is hard to figure out the API of the ' boost library from the ' Code if you are not familiar with generalization Programming (just like me). Besides, there is no useful ' Hello World ' examples on the Internet to show the Boost library handling statistics (examples on webpage C + + statistical distributions in Boost are a bit complicated and the header files are not included).

Therefore, I made up following example to show how to get the CDF of Poisson distribution with boost C + + library:

#include <boost/math/distributions/poisson.hpp>
#include <iostream>

using namespace std;
using namespace Boost::math;

int main ()
{
        poisson_distribution<> P (2.9);
        cout<< "Cdf:ppois (1,2.9) =" <<CDF (p,1) <<endl;

        return 0;
}

references:http://www.boost.org/doc/libs/1_52_0/libs/math/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/ Dists/poisson_dist.html C + + statistical distributions in Boost Http://www.datasimfinancial.com/forum/viewtopic.php?t =111

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.