Pseudo-random number generator
A pseudorandom number generator is a deterministic algorithm that uses an initial seed or internal state to produce a sequence of values with random-like properties.
Hacking Cryptography
A pseudorandom number generator uses a deterministic algorithm and an initial seed to produce a sequence of values that appears random.
- How it is used
- Distinguishes fast deterministic generation from cryptographic randomness and motivates secure seeding and generator selection.
- How deep it goes
- Implements an LCG, validates its output, and works through recovery of its modulus, multiplier, increment, and state.
- Examples
- Uses C++ minstd_rand and a Go LCG with seed 42, then clones an LCG from generated outputs.
- What you can do after
- Evaluate/understand why deterministic PRNG output can be reproduced, cloned, and unsuitable for cryptographic use.
Read how Hacking Cryptography explains pseudo-random number generator →
Real-World Cryptography
A pseudorandom number generator is a deterministic algorithm that expands a secret seed into a sequence of computationally generated values designed to resemble random values.
- How it is used
- Supports fast generation of cryptographic randomness after operating systems collect and mix slower entropy sources.
- How deep it goes
- Explains seeds, deterministic output, indistinguishability, state protection, and secrecy properties without implementation-level construction details.
- Examples
- Uses TCP connection values, getrandom, BCryptGenRandom, /dev/urandom, C code, PHP code, and predictable-seed failures.
- What you can do after
- Operate/configure randomness safely by choosing OS-backed interfaces, waiting for adequate seeding, and avoiding predictable or noncryptographic generators.
Read how Real-World Cryptography explains pseudo-random number generator →
Learn Haskell by Example
A random value generator is a computation that produces random or pseudo-random values, often with controlled variation in size or complexity.
- How it is used
- Supplies varied inputs for property tests that search for implementation errors.
- How deep it goes
- Explains explicit state threading with a linear congruential generator, then defers general generation to System.Random and QuickCheck.
- Examples
- Demonstrates a state-threaded integer list, sorting tests, and an alphabet-rotation property falsified by invalid generated inputs.
- What you can do after
- Apply it via QuickCheck or custom generators to provide randomized, constrained inputs for pure-function properties.
Read how Learn Haskell by Example explains pseudo-random number generator →
Deep Learning with R, Third Edition
A pseudo-random number generation operation deterministically produces values that appear random from an algorithmic seed or key.
- How it is used
- Controls reproducible random operations in stateful R code and stateless JAX programs.
- How deep it goes
- Explains global state, explicit keys, reproducibility, and key splitting through runnable implementation examples.
- Examples
- Uses R uniform-noise generation, JAX normal sampling, repeated keys, and split keys.
- What you can do after
- Apply explicit seeds and JAX keys to reproduce results and generate fresh random values predictably.
Read how Deep Learning with R, Third Edition explains pseudo-random number generator →
Functional Programming in Scala, Second Edition
Pseudo-random number generation is the deterministic production of values that approximate randomness from an initial seed.
- How it is used
- Uses random number generation as a compact setting for learning how to make stateful APIs purely functional.
- How deep it goes
- Explains mutation, reproducibility, explicit state transitions, and compositional Rand abstractions, while deferring broader stateful effects.
- Examples
- Uses scala.util.Random, die rolling, SimpleRNG(42), explicit seed threading, and reproducible generated integers.
- What you can do after
- Build it from scratch as a pure seed-to-value-and-state function and compose it with Rand operations.
Read how Functional Programming in Scala, Second Edition explains pseudo-random number generator →
Functional Programming in C#, Second Edition
An algorithmic generator that deterministically produces a sequence of values that appears random.
- How it is used
- Models random-data generation for property-based testing, load testing, and simulation as an explicit stateful computation.
- How deep it goes
- Explains seed threading through integer generation, mapping, binding, and structured values, using deterministic pseudorandom algorithms.
- Examples
- Uses seeded Random output, a scrambled integer generator, and Boolean, character, pair, option, and list generators.
- What you can do after
- Build it from scratch: define seeded generators and compose them to produce primitive and structured values.
Read how Functional Programming in C#, Second Edition explains pseudo-random number generator →
Deep Learning with Python, Third Edition
- How it is used
- Provides repeatable random values while supporting stateless, vectorizable JAX computation.
- How deep it goes
- Contrasts NumPy’s hidden global state with JAX keys, key reuse, and deterministic splitting.
- Examples
- Shows NumPy random calls and JAX normal samples generated with reused or split keys.
- What you can do after
- Operate JAX random calls by creating a key and splitting it to obtain new deterministic values.
Read how Deep Learning with Python, Third Edition explains pseudo-random number generator →
Optimization Algorithms: AI techniques for design, planning, and control problems
A deterministically generated number sequence that exhibits statistical properties resembling randomness.
- How it is used
- Supports inexpensive, diverse initial-population sampling for exploration in population-based metaheuristic algorithms.
- How deep it goes
- Defines determinism and sampling trade-offs, then demonstrates seeded NumPy generation without deriving generator internals.
- Examples
- Uses seeded NumPy sampling of 200 values and compares pseudo-random, quasi-random, Sobol, Latin hypercube, and other sampling plots.
- What you can do after
- Apply it via NumPy to generate reproducible candidate populations for metaheuristic search.
Deep Learning with JAX
A deterministic algorithm that produces numbers that appear random from an internal state or seed.
- How it is used
- Supports reproducible stochastic operations such as initialization, augmentation, sampling, dropout, and simulation.
- How deep it goes
- Defines seeds, internal state, deterministic sequences, periods, and JAX key discipline.
- Examples
- Uses neural-network weights, image noise, rotations, random data splits, sampling, and parameter searches as applications.
- What you can do after
- Apply it via JAX keys to initialize parameters and generate controlled random values without hidden generator state.
Read how Deep Learning with JAX explains pseudo-random number generator →
Clojure: The Essential Reference
A pseudorandom number generator is a deterministic algorithm that produces number sequences with statistical properties resembling random sequences.
- How it is used
- Supports practical random selection such as percentage-based A/B feature rollouts.
- How deep it goes
- Defines contracts, ranges, types, and outputs, then sketches linear congruential generation and repeating periods.
- Examples
- Demonstrates feature rollouts, sampled negative integers, random survey progress, image noise, and visible generator patterns.
- What you can do after
- Apply rand and rand-int to generate bounded doubles or integers for practical randomized behavior.
Read how Clojure: The Essential Reference explains pseudo-random number generator →
Learn Go with Pocket-Sized Projects
A random number generator is a procedure or system that produces values intended to follow a specified randomness model.
- How it is used
- Selects a random word from a corpus for a terminal word game.
- How deep it goes
- Explains bounded generation, algorithmic sources, package tradeoffs, and seeding, but does not detail generator algorithms.
- Examples
- Demonstrates selecting a corpus word with rand.Intn and testing membership across multilingual sample words.
- What you can do after
- Build random corpus selection with Go's math/rand and test its result without assuming a specific output.
Read how Learn Go with Pocket-Sized Projects explains pseudo-random number generator →
Also covered in
- Learn C++ by Example
- Pandas Workout: 200 exercises to make you a stronger data analyst
- Server-Side WebAssembly
- Type-Driven Development with Idris
- Just Use Postgres!
- API Design Patterns
- Get Programming: Learn to code with Python
- Classic Game Programming on the NES: Make your own retro video game
- Object-Oriented Software Design in C++
- Grokking Web Application Security
- Tiny Python Projects: Learn coding and testing with puzzles and games
- Classic Computer Science Problems in Swift: Essential techniques for practicing programmers
What to know first
- stateState is information describing the condition or configuration of a system or computation at a particular time that may influence its behavior or subsequent transitions.
- floating-point arithmeticFloating-point arithmetic is numerical computation using finite-precision representations of real numbers, which can introduce rounding and range errors.
- PythonPython is a high-level, general-purpose, dynamically typed programming language with readable syntax and support for multiple programming paradigms.
- arrayAn array is an ordered collection of elements organized in one or more dimensions and accessible by position or index.
Related concepts
- random seedconfigured by · A random seed is a value that initializes a pseudorandom process and determines its subsequent sequence of outputs.
- cryptographically secure random number generatorincludes · A cryptographically secure random number generator produces computationally unpredictable values while resisting prediction and recovery of its internal state by feasible adversaries.
- linear congruential generatorincludes · A linear congruential generator is a deterministic pseudorandom number generator that updates its state using a linear recurrence modulo a fixed integer.
- stateful computationkind of · A stateful computation takes a state and potentially other arguments, then returns a new state and potentially a result.
- tupleproduces · A tuple is a finite, ordered collection of values grouped as a single composite value, often with elements of different types.
- true random number generatorincludes · A true random number generator produces unpredictable values by sampling nondeterministic physical phenomena rather than relying solely on deterministic algorithms.
Questions about pseudo-random number generator
What is pseudo-random number generator?
A pseudorandom number generator is a deterministic algorithm that uses an initial seed or internal state to produce a sequence of values with random-like properties.
Which Manning books explain pseudo-random number generator?
Hacking Cryptography, Real-World Cryptography, Learn Haskell by Example, Deep Learning with R, Third Edition, Functional Programming in Scala, Second Edition, Functional Programming in C#, Second Edition, Deep Learning with Python, Third Edition, Optimization Algorithms: AI techniques for design, planning, and control problems and 3 more.
What should I know before learning pseudo-random number generator?
Manning books that teach pseudo-random number generator usually introduce state, floating-point arithmetic, Python and array first.
What kinds of pseudo-random number generator are there?
Kinds of pseudo-random number generator include cryptographically secure random number generator, linear congruential generator and true random number generator.
What is pseudo-random number generator a kind of?
Pseudo-random number generator is a kind of stateful computation. A stateful computation takes a state and potentially other arguments, then returns a new state and potentially a result.
What is pseudo-random number generator also called?
Pseudo-random number generator is also called pseudorandom number generator or PRNG.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.










