What is the random number generator in python and numpy?

import random
import numpy.random

What is the algorithm for random and numpy.random. Usually Mersenne Twister is the default generator for matlab, and there are choice to choose which generator to use. What about python, is there a choice for random generator?

Upvotes: 4

Views: 1198

Answers (1)

Nils Werner
Nils Werner

Reputation: 36739

Both cpython random and numpy.random use Mersenne Twister.

Both cpython random and numpy.random use /dev/(u)random on UNIX and CryptGenRandom on Windows for entropy.

Cpython allows to use Wichman Hill as an alternative PRNG, numpy does not (however you can use random.WichmanHill to fill a previously allocated array).

Upvotes: 4

Related Questions