liveBook · Manning

Normal distribution

As explained in Learn C++ by Example

The normal distribution is a continuous probability distribution characterized by a symmetric bell-shaped density determined by its mean and standard deviation.

A normal distribution makes values near an average more likely while still allowing extreme values. Its parameters are a mean and standard deviation, not minimum and maximum limits. section 6.2.1

Normally distributed blob steps

A C++ random blob can use std::normal_distribution{2.0, 1.0} to choose each step. Compared with a uniform distribution, this makes steps near 2 more common, while larger or smaller steps remain possible. The resulting value is converted to an integer before updating the blob's position. section 6.2.1

    Race::RandomBlob another_rnd_blob{
       std::default_random_engine{ rd() },
       std::normal_distribution{2.0, 1.0}
   };

Inspect the normal-distribution configuration used by the random blob. section 6.2.1

How Learn C++ by Example covers it

How deep it goes
Defines mean and standard deviation through a worked C++ example, but stops short of deriving the density function.
Examples
Uses random blob steps, std::normal_distribution{2.0, 1.0}, and a comparison with uniform steps from zero through four.
What you can do after
Apply it via C++11's random library to make values near a chosen mean more likely.
How it connects
Connects normal distribution with random number generators, probability distributions, uniform distribution, mean, and standard deviation.

Also explained in

Compare how 16 books explain normal distribution →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn C++ by Example. The section links point to the parts of the book it draws on.