Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Non Sequitur: An exploration of Python's random...

Non Sequitur: An exploration of Python's random module

An exploration of Python's random module for the curious programmer, this talk will give a little background in statistics and pseudorandom number generation, explain the properties of python's choice of pseudorandom generator and explore through visualizations the different distributions provided by the module.

Jair Trejo

July 24, 2014
Tweet

More Decks by Jair Trejo

Other Decks in Programming

Transcript

  1. 4.77 Counter({ '9': 14, '2': 12, '8': 12, '3': 11,

    '4': 10, '6': 9, '1': 8, '0': 8, '5': 8, '7': 8})
  2. 7638, 3390, 4921, 2162, 6742, 4545, 6570, 1649, 7192, 7248,

    5335, 4622, 3628, 1623, 6341, 2082, 3347, 2024, 965, 3122, 7468, 7710, 4441, 7224, 1861, 4633, 4646, 5853, 2576, 6357, 4114, 9249, 5440, 5936, 2360, 5696, 4444, 7491, 1150, 3225, 4006, 480, 3040, 2416, 8370, 569, 2376, 6453, 6412, 1137, 2927, 5673, 1829, 3452, 9163, 9605, 2560, 5536, 6472, 8867, 6236, 8876, 7833, 3558, 6593, 4676, 8649, 8052, 8347, 6724, 2121, 4986, 8601, 9772, 4919, 1965, 8612, 1665, 7722, 6292, 5892, 7156, 2083, 3388, 4785, 8962, 3174, 742, 5056, 5631, 7081, 1405, 9740, 8676, 2729, 4474, 166, 2755, 5900, 8100
  3. Conclusions • The definition of randomness is more a philosophical

    than a mathematical problem. • But we can use mathematical definitions that are useful for our purposes. • If we need sequences that are deterministic, but behave as if random, we can use pseudo-random number generation. • If we need numbers that are completely unpredictable, we need sources of entropy like input devices, noise measurements or other external sources. • For most of our random number needs, python provides more than adequate capabilities.
  4. 10 PRINT CHR$(205.5+RND(1)); : GOTO 10 By Nick Montfort, Patsy

    Baudoin, John Bell, Ian Bogost, Jeremy Douglass, Mark C. Marino, Michael Mateas, Casey Reas, Mark Sample and Noah Vawter
  5. On randomness in cryptography! http://blog.cloudflare.com/why-randomness-matters On random number generators testing!

    http://www.fourmilab.ch/hotbits/statistical_testing/stattest.html On the possible NSA backdoor into RSA’s random number generator! http://arstechnica.com/security/2014/01/how-the-nsa-may-have-put-a-backdoor rsas-cryptography-a-technical-primer/