random seed
The starting value of a pseudo-random number generator; the same seed always produces the same sequence of numbers.
In more detail
Fixing the seed, for example with random.seed(42) in Python, makes every run produce the same random choices, so bugs are reproducible and test results can be compared. Without a seed, generators usually start from an unpredictable value. Seeded generators are predictable by design, so never use them for security; use a cryptographically secure source such as Python's secrets module instead.
Examples
rng = random.Random(7)In this course: Seeding makes randomness repeatable, but a test that depends on a seed is coupled to the number and order of every random call in between. Passing in a generator that returns a chosen value is usually a clearer way to test.Related terms
- hash randomisation — Mixing a secret random value, chosen when a process starts, into string hashing so that hash values cannot be predicted from outside.
- deterministic — Always producing the same result from the same inputs, with nothing left to chance or timing.
- random module — The standard library module for pseudo-random numbers and random choices, such as randrange(10) or choice(colours).
- pseudo-random number — A number produced by a formula that looks random but is completely determined by where the sequence started.
- jitter — A random amount added to or taken from a retry delay so that many clients do not all retry at the same moment.
- random number generator — Code that produces unpredictable-looking numbers or choices, such as Python's random module.
- flaky test — A test that sometimes passes and sometimes fails on the same code, because it depends on something it does not control.
Taught in
- What A Hash Function Promises — Algorithms & Data Structures for Working Engineers
- Collisions In Practice And Hash Flooding — Algorithms & Data Structures for Working Engineers
- Comparison Sorts: Insertion, Merge And Quicksort — Algorithms & Data Structures for Working Engineers
- Counting And Radix Sort: Beating N Log N — Algorithms & Data Structures for Working Engineers
- Sorting In Real Systems: Stability, Keys And External Sort — Algorithms & Data Structures for Working Engineers
- Asymmetric Cryptography: RSA, ECC & Diffie-Hellman — Cybersecurity Fundamentals, GRC & Cryptography
- Data States: Security at Rest, in Transit, and in Use — Cybersecurity Fundamentals, GRC & Cryptography
- Internal Audits, Sampling & Evidence Chains — Cybersecurity Fundamentals, GRC & Cryptography
- Dates, Times And Random — Hands-on Python: Complete Video Course & Book
- Retries, Backoff And Jitter — Scalable System Design & Distributed Architecture
- Worked Design One: Ticket Booking, Correctness First — Scalable System Design & Distributed Architecture
- Testing Time And Randomness — Automated Testing, TDD & Quality Engineering
- math, random And platform — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep
- Modules Sprint — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep
- Mock, Review And Exam Day — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep