Seeds
A seed initializes a random number generator.
rng = np.random.default_rng(42)
The seed does not make the values non-random in purpose. It makes the sequence repeatable.
Same seed, same sequence
Same seed gives same sequence
Ready to run.
Both generators start from the same state, so they produce the same sequence.
One generator advances its state whenever it draws values. Calling the same generator twice therefore produces the next values, not a repeat:
Create a new generator from the recorded seed when you need to rerun the same sequence from its beginning.
Different seed, different sequence
Different seeds usually produce different sequences.
A seed is part of the experiment
If a result depends on randomness, record the seed with the result.
Later, a reader can rerun the same random choices.
What is the main purpose of setting a seed in these lessons?
Select one choice, then check.
Hint
A seed lets a new generator return to the same initial state.
Solution
The purpose here is to make the random choices repeatable. The seed initializes the generator; it does not make every value identical or make the generator suitable for security.