4
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?

1 Answer 1

4

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).

Sign up to request clarification or add additional context in comments.

2 Comments

Can we change the generator to others?
Note that there is work going on to add more random number generators to numpy: github.com/numpy/numpy/issues/6967

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.