1

in my previous post I was asking how to generate numbers following a normal distribution.

Since I have also other distributions to generate and I saw 3 libraries might provide them (GSL, TechnicalReport1(doc link?), Boost), I was wondering which one you would choose.

As a side note: the reference platform for my application is a GNU/Linux system and performance is a matter.

Community
  • 1
  • 1
puccio
  • 2,974
  • 8
  • 27
  • 20

4 Answers4

4

Take Boost it is quite popular and well designed for C++.

GSL is very good library that gives tools far behind distributions, but it is covered by GPL (not LGPL) meaning that if you want to develop non-GPL applications and distribute them, you can't.

Artyom
  • 29,986
  • 21
  • 123
  • 211
3

Here are some notes on getting started with random number generation using C++ TR1.

John D. Cook
  • 28,911
  • 10
  • 65
  • 93
2

Mersenne twister gives uniformly distributed numbers. There are two common approaches to generating normally distributed numbers from them:

  1. Box-Muller transform

  2. Ziggurat method

In my experience, the Ziggurat is 2x faster in Java, because it calls slow log/exp functions much less often than Box-Muller. I don't know how it is in C++.

quant_dev
  • 6,081
  • 1
  • 33
  • 55
1

Boost is nice because it's cross platform. Honestly, though, if you just need the numbers to not be cryptographically secure, a mersenne twister will be very fast from any of those libraries. If it's a bottleneck, just do some tests to find which is fastest.

rlbond
  • 62,751
  • 55
  • 170
  • 224