SlideShare a Scribd company logo
Non Sequitur
An exploration of Python's random module
Jair Trejo, EuroPython 2014
Jair Trejo
Director of Operations at Vinco Orbis
Non sequitur
Non sequitur
Non sequitur
Non sequitur
Non sequitur
Random sample
Simulation
552433147702632768969101985048
552433147702632768969101985048
552433147702632768969101985048
552433147702632768969101985048
552433147702632768969101985048
552433147702632768969101985048
552433147702632768969101985048
552433147702632768969101985048
552433147702632768969101985048
552433147702632768969101985048
14159265358979323846
26433832795028841971
69399375105820974944
59230781640628620899
86280348253421170679
4.77
Counter({
'9': 14,
'2': 12,
'8': 12,
'3': 11,
'4': 10,
'6': 9,
'1': 8,
'0': 8,
'5': 8,
'7': 8})
Non sequitur
Non sequitur
Non sequitur
14159265358979323846
26433832795028841971
69399375105820974944
59230781640628620899
86280348253421170679
3.1415926535897932384
626433832795028841971
693993751058209749445
923078164062862089986
280348253421170679
Non sequitur
Non sequitur
Non sequitur
Non sequitur
Non sequitur
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
Non sequitur
Non sequitur
7, 23, 41, 59, 89
Non sequitur
Non sequitur
Non sequitur
Non sequitur
Non sequitur
Non sequitur
Non sequitur
Non sequitur
Non sequitur
Python’s random module source code
Non sequitur
Non sequitur
import random
r = random.Random(seed)
r.random()
r.randrange(max)
r.random() * max
r.randrange(start, stop)
start + r.randrange(stop - start)
r.randrange(start, stop, step)
r.random()
r.randrange(start, stop, step)
r.randint(a, b)
r.choice(a_sequence)
r.sample(population, how_many)
r.shuffle(a_list)
sorted(a_list, key=lambda e: r.random())
Non sequitur
Non sequitur
Non sequitur
Non sequitur
Non sequitur
r.triangular
r.gammavariate
r.betavariate
r.paretovariate
r.weibullvariate
Non sequitur
import random
!
random.random()
random.WichmannHill
random.SystemRandom
randomdotorg.RandomDotOrg
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.
References
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
The art of computer programming, Volume 2
Seminumerical Algorithms
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/
Thank you!

More Related Content

PPTX
Coderstrust Presentation on C Language
PPTX
Non sequitur, either- or, faulty analogy, and circular reasoning fallacies
PPT
Chapter 10
PPTX
Hasty or sweeping generalization
PPTX
Non sequitur
PPT
Arguments of Definition
PPTX
Logic arguments and_fallacies
PPTX
Analyzing and evaluating arguments
Coderstrust Presentation on C Language
Non sequitur, either- or, faulty analogy, and circular reasoning fallacies
Chapter 10
Hasty or sweeping generalization
Non sequitur
Arguments of Definition
Logic arguments and_fallacies
Analyzing and evaluating arguments

Similar to Non sequitur (20)

PPTX
FUNCTIONS IN PYTHON[RANDOM FUNCTION]
PDF
functions2-200924082810.pdf
PPTX
Pseudorandom number generators powerpoint
PPTX
2. Modelling and Simulation in computer 2.pptx
PDF
Python Programming - IX. On Randomness
PPTX
CMSC 201 - Lec19 - Modules and Random Numbers.pptx
PDF
What is pseudo random number
PDF
40120140502003
PDF
Random thoughts on IoT
PPT
lections tha detail aboot andom nummerss
PPTX
Information and network security 30 random numbers
PPT
Lecture06-Random-Number-Genedawrators.ppt
PDF
FPGA-based Design System for a Two-Segment Fibonacci LFSR Random Number Gener...
PPTX
Cryptography using probability
PDF
Pseudo-Random Number Generators: A New Approach
PDF
J45015460
PPTX
Unit-3 of mathematical foundation of ai ml
PDF
Random number generation (in C++) – past, present and potential future
PPTX
Random_Number_Generation_Algorithms.pptx
PPTX
Amanda Sopkin - Computational Randomness: Creating Chaos in an Ordered Machin...
FUNCTIONS IN PYTHON[RANDOM FUNCTION]
functions2-200924082810.pdf
Pseudorandom number generators powerpoint
2. Modelling and Simulation in computer 2.pptx
Python Programming - IX. On Randomness
CMSC 201 - Lec19 - Modules and Random Numbers.pptx
What is pseudo random number
40120140502003
Random thoughts on IoT
lections tha detail aboot andom nummerss
Information and network security 30 random numbers
Lecture06-Random-Number-Genedawrators.ppt
FPGA-based Design System for a Two-Segment Fibonacci LFSR Random Number Gener...
Cryptography using probability
Pseudo-Random Number Generators: A New Approach
J45015460
Unit-3 of mathematical foundation of ai ml
Random number generation (in C++) – past, present and potential future
Random_Number_Generation_Algorithms.pptx
Amanda Sopkin - Computational Randomness: Creating Chaos in an Ordered Machin...
Ad

Recently uploaded (20)

PPTX
Module 8- Technological and Communication Skills.pptx
PPTX
Nature of X-rays, X- Ray Equipment, Fluoroscopy
PPTX
communication and presentation skills 01
PDF
Visual Aids for Exploratory Data Analysis.pdf
PDF
Abrasive, erosive and cavitation wear.pdf
PDF
Soil Improvement Techniques Note - Rabbi
PDF
Categorization of Factors Affecting Classification Algorithms Selection
PPTX
Management Information system : MIS-e-Business Systems.pptx
PDF
Accra-Kumasi Expressway - Prefeasibility Report Volume 1 of 7.11.2018.pdf
PDF
Exploratory_Data_Analysis_Fundamentals.pdf
PDF
August 2025 - Top 10 Read Articles in Network Security & Its Applications
PDF
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
PDF
COURSE DESCRIPTOR OF SURVEYING R24 SYLLABUS
PPTX
Current and future trends in Computer Vision.pptx
PPTX
AUTOMOTIVE ENGINE MANAGEMENT (MECHATRONICS).pptx
PDF
distributed database system" (DDBS) is often used to refer to both the distri...
PPT
Total quality management ppt for engineering students
PPTX
Fundamentals of safety and accident prevention -final (1).pptx
PDF
737-MAX_SRG.pdf student reference guides
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
Module 8- Technological and Communication Skills.pptx
Nature of X-rays, X- Ray Equipment, Fluoroscopy
communication and presentation skills 01
Visual Aids for Exploratory Data Analysis.pdf
Abrasive, erosive and cavitation wear.pdf
Soil Improvement Techniques Note - Rabbi
Categorization of Factors Affecting Classification Algorithms Selection
Management Information system : MIS-e-Business Systems.pptx
Accra-Kumasi Expressway - Prefeasibility Report Volume 1 of 7.11.2018.pdf
Exploratory_Data_Analysis_Fundamentals.pdf
August 2025 - Top 10 Read Articles in Network Security & Its Applications
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
COURSE DESCRIPTOR OF SURVEYING R24 SYLLABUS
Current and future trends in Computer Vision.pptx
AUTOMOTIVE ENGINE MANAGEMENT (MECHATRONICS).pptx
distributed database system" (DDBS) is often used to refer to both the distri...
Total quality management ppt for engineering students
Fundamentals of safety and accident prevention -final (1).pptx
737-MAX_SRG.pdf student reference guides
Automation-in-Manufacturing-Chapter-Introduction.pdf
Ad

Non sequitur