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