The Cumulative Distribution Function(CDF) of Poisson distribution can be easily calculated by R function ppois() or octave/Matlab function poisspdf(). However, it is not 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 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 is 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:*