Python Random numbers Peter Wad Sackett.

Slides:



Advertisements
Similar presentations
Random Number Generation Graham Netherton Logan Stelly.
Advertisements

Random variables 1. Note  there is no chapter in the textbook that corresponds to this topic 2.
1 Random numbers Random  completely unpredictable. No way to determine in advance what value will be chosen from a set of equally probable elements. Impossible.
Random numbers in Python Nobody knows what’s next...
Section The Idea of Probability Statistics.
Genome Sciences 373 Genome Informatics Quiz Section 9 May
Chapter 11: understanding randomness (Simulations)
Introduction to Computing Using Python Chapter 6  Encoding of String Characters  Randomness and Random Sampling.
Copyright © 2010 Pearson Education, Inc. Unit 3: Gathering Data Chapter 11 Understanding Randomness.
Slide 11-1 Copyright © 2004 Pearson Education, Inc.
1-1 Copyright © 2015, 2010, 2007 Pearson Education, Inc. Chapter 10, Slide 1 Chapter 10 Understanding Randomness.
Understanding Randomness Chapter 11. Why Be Random? What is it about chance outcomes being random that makes random selection seem fair? Two things: –
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 11 Understanding Randomness.
Lecture PowerPoint Slides Basic Practice of Statistics 7 th Edition.
Xin Liu Feb 4, * Use midterm questions for previous 231/217 midterms for practices * ams
Slide Understanding Randomness.  What is it about chance outcomes being random that makes random selection seem fair? Two things:  Nobody can.
Random numbers in C++ Nobody knows what’s next....
Random Numbers RANDOM VS PSEUDO RANDOM. Truly Random numbers  From Wolfram: “A random number is a number chosen as if by chance from some specified distribution.
Chapter 10 Understanding Randomness. Why Be Random? What is it about chance outcomes being random that makes random selection seem fair? Two things: –
1 Chapter 11 Understanding Randomness. 2 Why Be Random? What is it about chance outcomes being random that makes random selection seem fair? Two things:
Section The Idea of Probability AP Statistics
Statistics 11 Understanding Randomness. Example If you had a coin from someone, that they said ended up heads more often than tails, how would you test.
Module 9.2 Simulations. Computer simulation Having computer program imitate reality, in order to study situations and make decisions Applications?
1 Building Java Programs Chapter 5 Lecture 11: Random Numbers reading: 5.1, 5.6.
Uncertainty and Games (Ch. 15). Uncertainty If a game outcome is certain can it achieve meaningful play? –Example of such a game? Two kinds of uncertainty:
Chapter 11 Understanding Randomness. What is the most important aspect of randomness? It must be fair. How is this possible? 1) Nobody can guess the outcome.
Dieharder An Open Source Random Number Generator Tester Robert G. Brown Physics Department Duke TechExpo 2011.
CS 115 Lecture Augmented assignment; Boolean logic; random numbers
CSc 110, Spring 2017 Lecture 12: Random Numbers
Recap: If, elif, else If <True condition>:
Compsci 6/101: I Python Techniques for looping
Why they aren't really random
Building Java Programs
Building Java Programs
MONTE CARLO SIMULATION
Python Random numbers Peter Wad Sackett.
Hatice Kübra Eryılmaz CMPE220/Fall
Today’s Objectives Review the important points of classes
Random Numbers Until now, all programs have behaved deterministically - completely predictable and repeatable based on input values Some applications.
Warmup The “experts” think the Braves are still rebuilding and will only win 46% of their games this season. Using a standard deck of cards (52 cards,

CSC 110 – Fluency in Information Technology Chapter 20: The random function and Chaos Dr. Curry Guinn.
CSc 110, Autumn 2016 Lecture 13: Random Numbers
Understanding Randomness
Unit 6 Probability.
Friday, October 7, 2016 Write a random number between 1 and 10 on a post- it note on your desk Warm-up Discuss with your group & make a list What games.
Random numbers Taken from notes by Dr. Neil Moore
Understanding Randomness
Understanding Randomness
Understanding Randomness
Probability and Statistics
Development of Inter-model differences
Pseudo-random numbers
Random vs pseudo random
Pick a number, any number …
Random Numbers In today’s lesson we will look at:
Lecture 2 – Monte Carlo method in finance
CS 115 Lecture 7 Augmented assignment; Boolean logic; random numbers
Building Java Programs
Homework #5 — Monte Carlo Simulation
Understanding Randomness
Last Class We Covered What makes “good code” good Top down design
5.1: Randomness, Probability and Simulation
WARM UP: Solve the equation for height for an age of 25.
CS150 Introduction to Computer Science 1
Computer Simulation Techniques Generating Pseudo-Random Numbers
Section 6.1 The Idea of Probability
Understanding Randomness
Building Java Programs
Presentation transcript:

Python Random numbers Peter Wad Sackett

The need for randomness Humans have an intrinsic need for randomness, possibly based on a need for fairness or ”having a chance”. Who would participate in a lottery or card game if the winning numbers/cards were not chosen by chance? Much of statistical theory is based on randomness and everyday practices like participating in experimental trials or surveys or performing your civic duty as juror are based on randomly selected people. Signal analysis must deal with random noise and (computer) simulations of various kinds expects or uses random events. Mutations - caused by exposure to radiation or chemicals – are random. Randomness is part of both our science and consciousness and the way we think about events. Quite often the randomness has some bias attached to it – whether we perceive it or not..

Types of randomness Truly random numbers - unpredictable Used in cryptography and gambling Expensive and hard to generate – based on quantum mechanics Pseudo random numbers – predictable Used everywhere, when true randomness is not required Cheap – based on a deterministic computer algorithm Seed A strong use-case for pseudo-random numbers is computer programs where you need to be able to repeat a run or eksperiment. By setting the seed (beginning point) you can repeat the series of ”random” numbers. Direction Circular list of numbers, where the next is generated from the previous

Python random library import random # Initializing the seed random.seed(’I am a string seed’) # Get a random integer from a range – similar to range myInt = random.randrange(1, 11) # Get a random element from a sequence myList = [’Yes’, ’No’, ’Maybe’, ”Don’t know”] myChoice = random.choice(myList) # Random shuffe of a sequence random.shuffle(myList) # Get a random float between 0 and 1 (1 not inclusive) myFloat = random.random() More random functions and distributions exists. https://docs.python.org/3/library/random.html

The nature of randomness