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


Hello,

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:

  #include<iostream>
  #include<iterator>
  #include<vector>
  #include<algorithm>
  #include<boost/random/poisson_distribution.hpp>
  #include<boost/random/variate_generator.hpp>
  #include<boost/random/mersenne_twister.hpp>

  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?" <<
endl;

    return 0;

 }

Thanks,
Mike



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net