liveBook · Manning

Mersenne Twister

Mersenne Twister is a family of deterministic pseudorandom number generators with very long periods, including MT19937 with period 2^19937−1.

How 2 Manning books explain it

Hacking Cryptography

A deterministic pseudorandom number generator family based on recurrences associated with Mersenne primes and designed to provide a very long period.

How it is used
Uses MT19937 to implement a practical pseudorandom generator and demonstrate why it fails for cryptographic applications.
How deep it goes
Explains state initialization, twisting, tempering, untempering, and full-state cloning, stopping short of the constants’ mathematical derivation.
Examples
Demonstrates Go implementation listings, default-seed test vectors, and a cloning test that matches 100 predicted outputs.
What you can do after
Diagnose MT19937 misuse, implement its state transformations, and reproduce an output-only state-cloning attack.

Read how Hacking Cryptography explains Mersenne Twister →

Learn C++ by Example

mt19937 is a C++ standard library pseudorandom number engine implementing the Mersenne Twister algorithm with a period of 2^19937−1.

How it is used
Generates pseudorandom integers for a guessing game and supports reproducible simulations or tests.
How deep it goes
Explains periods, seeds, engines, and distributions, then demonstrates one generated integer without developing the algorithm’s internals.
Examples
Uses a deliberately poor alternating generator, a 1–100 integer generator, and a random-number guessing game.
What you can do after
Apply it via std::random_device, std::mt19937, and std::uniform_int_distribution to generate bounded integers.

Read how Learn C++ by Example explains Mersenne Twister →

Related concepts

Questions about Mersenne Twister

What is Mersenne Twister?

Mersenne Twister is a family of deterministic pseudorandom number generators with very long periods, including MT19937 with period 2^19937−1.

Which Manning books explain Mersenne Twister?

Hacking Cryptography and Learn C++ by Example.

What is Mersenne Twister a kind of?

Mersenne Twister is a kind of 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.

What are the parts of Mersenne Twister?

Mersenne Twister includes state.

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.