Compare Random Number Distribution Generators

Learn to compare random number distribution generators.

We'll cover the following

The C++ Standard Library provides a selection of random number distribution generators, each with its own properties. In this recipe, we examine a function to compare the different options by creating a histogram of their output.

How to do it

Like the random number engines, the distribution generators have some common interface elements. Unlike the random number engines, the distribution generators have a variety of properties to set. We can create a template function to print a histogram of the various distributions, but the initializations of the various distribution generators vary significantly:

  • We start with some constants:

Get hands-on with 1200+ tech skills courses.