I want to generate random numbers from one of the following distribution in C++. I haven't been able to find any libraries though. Do they exist?

In order of preference:

  1. Three parameter inverse Gaussian
  2. Three parameter Lognormal
  3. Three parameter Log-Logistic
  4. Four parameter Pearson Type 6
  5. Generalized Pareto
  • $\begingroup$ I think this would be better in Stack Overflow. $\endgroup$ – Clark Henry Jul 25 '14 at 19:12

I don't think there is a c++ library, but you can easily write your code:

1) on wikipedia there is a method to simulate a two parameters inverse gaussian http://en.wikipedia.org/wiki/Inverse_Gaussian_distribution. You can use this and then shift the distributon to have a three parameters distribution

2) you can simulate a normal variable with the same two parameters of the log normal, take the exponential, shifting by the value of the third parameter

3) maybe you can simulate a logistic distribution and then take the log, but i am not sure

4) i don't know this distribution

5)again wikipedia helps you http://en.wikipedia.org/wiki/Generalized_Pareto_distribution#Generating_generalized_Pareto_random_variables


With some more searching I found a library by Richard Saucier which contained the three parameter lognormal among other distributions. The documentation for the library is here.

Thank you niandra82 for your reply. When I looked at the library code you were quite right in that it would have been easy enough to write myself. The wikipedia definitions of the distributions make things seem far more complicated than needed and I was put off though!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.