Learn Before
Example
Simulating a Fair Coin Toss
To simulate an event with a 0.5 probability, such as a fair coin toss, we can utilize a random number generator that outputs continuous values in the interval [0, 1]. By testing whether the generated float is greater than 0.5, we assign the two outcomes with equal likelihood, since the probability of the value falling in either the [0, 0.5] or (0.5, 1] sub-interval is exactly .
0
1
Updated 2026-05-02
Tags
D2L
Dive into Deep Learning @ D2L