0 / 34

Invite others

Progress

0 / 34

Random Arrays

Random module:

rng = np.random.default_rng(42)
rng.random((3,))        # 3 floats
rng.integers(1, 7, 5)   # 5 ints 1-6
rng.normal(0, 1, (2,3)) # normal dist

A seed makes results reproducible.

Why this matters

Train/validation splits, simulations, and initialized weights all need randomness—but reproducible randomness when you debug or share results. The Generator API is the modern, explicit way to do that.

Without a seed, "it worked yesterday" is often just a different random draw.

ResourcesDocs, references & more — opens in a new tab
🎯 Your Task

Seed 0. Generate rolls10 ints from 1 to 6.

rng = np.random.default_rng(0), rng.integers(1, 7, 10)
exercise.py
⌘⏎ run · ⌘← → nav
Output
Run your code to see output here.