Boost logo

Boost Users :

Subject: [Boost-users] trouble with boost/random/poisson_distribution and large lambda
From: Michael King (wmichaelking1_at_[hidden])
Date: 2011-06-22 18:49:18


I am new to the boost mailing list, so I apologize before hand if this is
not the appropriate forum for this question.

I have been using boost/random recently and have encountered what appears to
be a problem with poisson variate generators with large lambda values.

The random values can't seem to get much higher than 800 regardless of what
value lambda is.

For example:


  using namespace boost;
  using namespace std;

  int main() {

    mt19937 gen;

    double lambda = 1000.;
    poisson_distribution<int, double> pois(lambda);
    variate_generator<mt19937&, poisson_distribution<int, double> >
rpois(gen, pois);

    // generate 10 random poisson variables
    vector<double> sample(10);

    generate(sample.begin(), sample.end(), rpois);

    cout << "Simulating from Poisson Random Variable with lambda=" << lambda
<< endl;
    cout << "\nSample: ";
    copy(sample.begin(), sample.end(), ostream_iterator<int>(cout, " "));
    cout << "\n\nShouldn't the numbers be a little closer to 1,000?" <<

    return 0;



Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at