Difference between revisions of "Randomness"

From Noisebridge
Jump to: navigation, search
(some random notes, quotes, & code)
 
(No difference)

Latest revision as of 20:44, 7 January 2015

some random notes, quotes, & code

Wikipedia

Although randomness had often been viewed as an obstacle and a nuisance for many
centuries, in the twentieth century computer scientists began to realize that
the deliberate introduction of randomness into computations can be an effective
tool for designing better algorithms.
Unlike classical information theory, algorithmic information theory gives formal,
rigorous definitions of a random string and a random infinite sequence that do not
depend on physical or philosophical intuitions about nondeterminism or likelihood.

Python

Python uses the Mersenne Twister as the core generator. It produces
53-bit precision floats and has a period of 2**19937-1 [...] However,
being completely deterministic, it is not suitable for all purposes,
and is completely unsuitable for cryptographic purposes.

(Mersenne Twister replaced Wichmann-Hill as default generator in Python 2.3)

The random module also provides the SystemRandom class which uses the
system function os.urandom() to generate random numbers from sources
provided by the operating system.

example:

import random

foo = random.getrandbits(1024) # mersenne twister, returns arbitrarily long integer
print(bin(foo))

altrand = random.SystemRandom() # not available on all systems, assumes entropy source

bar = altrand.getrandbits(1024)
print(bin(bar))