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
  • 3,054
  • 8
  • 29
  • 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
  • 31,019
  • 21
  • 127
  • 215
3

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

John D. Cook
  • 29,517
  • 10
  • 67
  • 94
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,181
  • 1
  • 34
  • 57
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
  • 65,341
  • 56
  • 178
  • 228