Search⌘ K
AI Features

Compare Random Number Distribution Generators

Explore how to compare various C++ random number distribution generators by creating histograms of their outputs. Understand the differences in initialization and parameters, and learn to visualize distributions using template functions and maps for better analysis of random algorithms.

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: ...