Distribution generators in C++

c-plus-plus distributions randomization std-library

I went looking around for generators to produce normal distributions in C++. It turns out this has been a thing since C++11! and is in the std namespace. You’ll need to #include <random>. There’s also a uniform distribution, and many more. The references are great, so I will just leave them here for me to come back to when I forget the syntax:

Normal distribution reference.

Uniform distribution reference.

An important cavaet – the random number generator choice matters. See more at another TIL.

© Amy Tabb 2018 - 2023. All rights reserved. The contents of this site reflect my personal perspectives and not those of any other entity.