Invasion Percolation: Randomness Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See

Slides:



Advertisements
Similar presentations
Input and Output Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Advertisements

Introduction Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Introduction Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Python Crash Course Accuracy 3 rd year Bachelors V1.0 dd Hour 7.
Slicing Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Floating Point Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Control Flow Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Central Limit Theorem.
Sequences Ordered Patterns. 8/31/2013 Sequences 2 The art of asking the right questions in mathematics is more important than the art of solving them.
Computability and Complexity 20-1 Computability and Complexity Andrei Bulatov Random Sources.
Using random numbers Simulation: accounts for uncertainty: biology (large number of individuals), physics (large number of particles, quantum mechanics),
Random Numbers Dick Steflik. Pseudo Random Numbers In most cases we do not want truly random numbers –most applications need the idea of repeatability.
Pseudorandom Number Generators
Data Structures Introduction. What is data? (Latin) Plural of datum = something given.
Random numbers in Python Nobody knows what’s next...
15-853Page :Algorithms in the Real World Generating Random and Pseudorandom Numbers.
The Binomial Distribution: Using Tables © Christine Crisp “Teach A Level Maths” Statistics 1.
Dennis Shasha From a book co-written with Manda Wilson
Mechanics Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
COMPE 111 Introduction to Computer Engineering Programming in Python Atılım University
College Algebra Fifth Edition James Stewart Lothar Redlin Saleem Watson.
Fixtures Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
STAY SAFE!! Don’t fall for the same old tricks !!.
2-5: Imaginary & Complex Numbers Unit 2 English Casbarro.
1-1 Copyright © 2015, 2010, 2007 Pearson Education, Inc. Chapter 10, Slide 1 Chapter 10 Understanding Randomness.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 11 Understanding Randomness.
Invasion Percolation: Assembly Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
CSC 110 Using Python [Reading: chapter 1] CSC 110 B 1.
Interface and Implementation Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Discrete Random Variables
Storage Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Copyright © 2006 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
2.2 Libraries and Clients Introduction to Programming in Java: An Interdisciplinary Approach · Robert Sedgewick and Kevin Wayne · Copyright © 2008 · December.
Factors, Prime Numbers & Composite Numbers. Definition Product – An answer to a multiplication problem. 7 x 8 = 56 Product.
Branches of Science Web-quest What is science? How many different branches of science are there? What is the difference between a scientific fact, law.
Javier Junquera Random numbers and the central limit theorem Alberto García.
Week 6. Statistics etc. GRS LX 865 Topics in Linguistics.
Section 5.1.  Three ways to answer this question: 1. Actually carry out an experiment 2. Develop a probability model 3. Start with a model, and then.
Copyright © 2010, 2007, 2004 Pearson Education, Inc. All Rights Reserved. Section 6-4 Sampling Distributions and Estimators.
Section Copyright © 2014, 2012, 2010 Pearson Education, Inc. Lecture Slides Elementary Statistics Twelfth Edition and the Triola Statistics Series.
Random numbers in C++ Nobody knows what’s next....
Copyright © 2010, 2007, 2004 Pearson Education, Inc. Lecture Slides Elementary Statistics Eleventh Edition and the Triola Statistics Series by.
Operators Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Let’s not leave anything to chance. How that process to generate random numbers takes places requires some complicated statistics that are outside the.
Chapter 10 Understanding Randomness. Why Be Random? What is it about chance outcomes being random that makes random selection seem fair? Two things: –
Exceptions Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
The man who knew 28% of mathematics. John Von Neumann ( ) Hans Bethe: Academic seminars (10.
Basics Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Copyright © Cengage Learning. All rights reserved. Sequences and Series.
To factor means to write a number or expression as a product of primes. In other words, to write a number or expression as things being multiplied together.
0 Simulation Modeling and Analysis: Input Analysis 7 Random Numbers Ref: Law & Kelton, Chapter 7.
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.
Chapter 3 Generating Uniform Random Variables. In any kind of simulation, we need data, or we have to produce them. Especially in Monte Marco simulation.
UNIFORM RANDOM NUMBER GENERATION Chapter 7 (first half) The goal is to generate a sequence of The goal is to generate a sequence of Uniformly distributed.
1.  How does the computer generate observations from various distributions specified after input analysis?  There are two main components to the generation.
Python Aliasing Copyright © Software Carpentry 2010
Program Design Invasion Percolation: Aliasing
Program Design Invasion Percolation: Testing
Today’s Objectives Review the important points of classes
Program Design Invasion Percolation: Resolving Ties
Program Design Invasion Percolation: Neighbors
6.4 Logarithmic & Exponential Equations
Random Numbers In today’s lesson we will look at:
Version Control Basic Operation Copyright © Software Carpentry 2010
Last Class We Covered What makes “good code” good Top down design
Version Control Introduction Copyright © Software Carpentry 2010
Random Number and Random Variate Generation
Program Design Invasion Percolation: Bugs
COSC 1306 COMPUTER SCIENCE AND PROGRAMMING
Program Design Invasion Percolation: The Grid
Presentation transcript:

Invasion Percolation: Randomness Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See for more information. Program Design

Invasion PercolationRandomness Need a 2D grid of random values

Program DesignInvasion PercolationRandomness Need a 2D grid of random values Uniformly distributed in some range 1..Z

Program DesignInvasion PercolationRandomness Need a 2D grid of random values Uniformly distributed in some range 1..Z Need to check the science on that

Program DesignInvasion PercolationRandomness assert N > 0, "Grid size must be positive" assert N%2 == 1, "Grid size must be odd" grid = [] for x in range(N): grid.append([]) for y in range(N): grid[-1].append(1)

Program DesignInvasion PercolationRandomness from random import seed, randint assert N > 0, "Grid size must be positive" assert N%2 == 1, "Grid size must be odd" assert Z > 0, "Range must be positive“ seed(S) grid = [] for x in range(N): grid.append([]) for y in range(N): grid[-1].append(randint(1, Z))

Program DesignInvasion PercolationRandomness from random import seed, randint assert N > 0, "Grid size must be positive" assert N%2 == 1, "Grid size must be odd" assert Z > 0, "Range must be positive“ seed(S) grid = [] for x in range(N): grid.append([]) for y in range(N): grid[-1].append(randint(1, Z))

Program DesignInvasion PercolationRandomness >>> from random import seed, randint >>> seed( ) >>> for i in range(5):... print randint(1, 10),

Program DesignInvasion PercolationRandomness >>> from random import seed, randint >>> seed( ) >>> for i in range(5):... print randint(1, 10), Standard Python random number library

Program DesignInvasion PercolationRandomness >>> from random import seed, randint >>> seed( ) >>> for i in range(5):... print randint(1, 10), Initialize the sequence of “random” numbers

Program DesignInvasion PercolationRandomness >>> from random import seed, randint >>> seed( ) >>> for i in range(5):... print randint(1, 10), Produce the next “random” number in the sequence

Program DesignInvasion PercolationRandomness >>> base = 17 # a prime >>> value = 4 # anything in 0..base-1 >>> for i in range(20):... value = (3 * value + 5) % base... print value, Here’s a simple “random” number generator:

Program DesignInvasion PercolationRandomness >>> base = 17 # a prime >>> value = 4 # anything in 0..base-1 >>> for i in range(20):... value = (3 * value + 5) % base... print value, base controls how long before values repeat

Program DesignInvasion PercolationRandomness >>> base = 17 # a prime >>> value = 4 # anything in 0..base-1 >>> for i in range(20):... value = (3 * value + 5) % base... print value, base controls how long before values repeat Once they do, values appear in exactly the same order as before

Program DesignInvasion PercolationRandomness >>> base = 17 # a prime >>> value = 4 # anything in 0..base-1 >>> for i in range(20):... value = (3 * value + 5) % base... print value, The seed controls where the sequence starts

Program DesignInvasion PercolationRandomness >>> base = 17 # a prime >>> value = 9 # anything in 0..base-1 >>> for i in range(20):... value = (3 * value + 5) % base... print value, The seed controls where the sequence starts Changing the seed slides values left or right

Program DesignInvasion PercolationRandomness >>> base = 17 # a prime >>> value = 9 # anything in 0..base-1 >>> for i in range(20):... value = (3 * value + 5) % base... print value, The seed controls where the sequence starts Changing the seed slides values left or right (We’ll use this fact when testing our program)

Program DesignInvasion PercolationRandomness This is a lousy “random” number generator

Program DesignInvasion PercolationRandomness This is a lousy “random” number generator Did you notice that 6 never appeared?

Program DesignInvasion PercolationRandomness This is a lousy “random” number generator Did you notice that 6 never appeared? That would probably distort our results...

Program DesignInvasion PercolationRandomness What happens when 6 does appear? >>> base = 17 >>> value = 6 >>> for i in range(20):... value = (3 * value + 5) % base... print value,

Program DesignInvasion PercolationRandomness >>> base = 17 >>> value = 6 >>> for i in range(20):... value = (3 * value + 5) % base... print value, How can we prove this won’t ever happen? What happens when 6 does appear?

Program DesignInvasion PercolationRandomness >>> base = 17 >>> value = 6 >>> for i in range(20):... value = (3 * value + 5) % base... print value, What happens when 6 does appear? How can we prove this won’t ever happen? Or that something subtler won't go wrong?

Program DesignInvasion PercolationRandomness Computers can’t generate real random numbers

Program DesignInvasion PercolationRandomness Computers can’t generate real random numbers But they can generate numbers with many of the same statistical properties as the real thing

Program DesignInvasion PercolationRandomness Computers can’t generate real random numbers But they can generate numbers with many of the same statistical properties as the real thing This is very hard to get right

Program DesignInvasion PercolationRandomness Computers can’t generate real random numbers But they can generate numbers with many of the same statistical properties as the real thing This is very hard to get right Never try to do it yourself

Program DesignInvasion PercolationRandomness Computers can’t generate real random numbers But they can generate numbers with many of the same statistical properties as the real thing This is very hard to get right Never try to do it yourself Always use a good library

Program DesignInvasion PercolationRandomness Computers can’t generate real random numbers But they can generate numbers with many of the same statistical properties as the real thing This is very hard to get right Never try to do it yourself Always use a good library...like Python’s

Program DesignInvasion PercolationRandomness Any one who considers arithmetical methods of producing random digits is, of course, in a state of sin. For, as has been pointed out several times, there is no such thing as a random number. There are only methods to produce random numbers, and a strict arithmetic procedure of course is not such a method. – John von Neumann

Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See for more information. May 2010 created by Greg Wilson