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