Random distributions are not one-size-fits-all (part 2.5)
I recently realized that I could try to implement the reuse-oriented distributions from part 2 using libdivide instead of native (hardware) division (modulo).
I recently realized that I could try to implement the reuse-oriented distributions from part 2 using libdivide instead of native (hardware) division (modulo).
In this part, we will look at different algorithms for generating uniformly distributed random numbers and determine whether they fit specific use cases better than Lemire's algorithm.
Recently I was again on CppCast, and again I talked about C++'s standard library support for random numbers. One of the things I said was that random distributions are not one-size-fits-all. This post is about how this applies to Lemire's algorithm for generating uniformly distributed integers.
Last week I wrote about the various problem with using C++'s standard library (mainly <random>) to generate random numbers. This week I will outline what I think are the (standardizable) solutions to fix the functionality in <random> and make it widely usable.
I found myself once again writing a long forum post about the problems with standard-provided random number generation facilities (both C++'s <random>, and C's rand) in C++. Since I keep writing these, I decided to write it all down into one blog post so that I can link it to people later.