Mathematics 202 Linear Algebra and Probability Spring 2011 Professor Allan B. Cruse Mathematics and Computer Science.

Slides:



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

Random Number Generation. Random Number Generators Without random numbers, we cannot do Stochastic Simulation Most computer languages have a subroutine,
Probability Distributions CSLU 2850.Lo1 Spring 2008 Cameron McInally Fordham University May contain work from the Creative Commons.
Exercise 4 1. Write a program that simulates coin tossing. For each toss of the coin the program should print Heads or Tails. Let the program toss the.
Chapter 4 Mathematical Expectation.
Discrete Event Simulation How to generate RV according to a specified distribution? geometric Poisson etc. Example of a DEVS: repair problem.
Random Numbers Dick Steflik. Pseudo Random Numbers In most cases we do not want truly random numbers –most applications need the idea of repeatability.
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.
Slide 1 Statistics Workshop Tutorial 4 Probability Probability Distributions.
AP Statistics Section 7.2 B Law of Large Numbers.
Section 5.1 What is Probability? 5.1 / 1. Probability Probability is a numerical measurement of likelihood of an event. The probability of any event is.
Chapter 1 Probability and Distributions Math 6203 Fall 2009 Instructor: Ayona Chatterjee.
CPSC 531: RN Generation1 CPSC 531:Random-Number Generation Instructor: Anirban Mahanti Office: ICT Class Location:
Stats Probability Theory. Instructor:W.H.Laverty Office:235 McLean Hall Phone: Lectures: M W F 2:30pm - 3:20am Arts 133 Lab: M 3:30 - 4:20.
CS 206 Introduction to Computer Science II 02 / 23 / 2009 Instructor: Michael Eckmann.
Lecture 5 Methods. Sometimes we want to perform the same sequence of operations multiple times in a program. While loops allow us to do this, they are.
CS 361 – Chapters 8-9 Sorting algorithms –Selection, insertion, bubble, “swap” –Merge, quick, stooge –Counting, bucket, radix How to select the n-th largest/smallest.
LECTURE 17 THURSDAY, 22 OCTOBER STA 291 Fall
1 1 Slide Simulation Professor Ahmadi. 2 2 Slide Simulation Chapter Outline n Computer Simulation n Simulation Modeling n Random Variables and Pseudo-Random.
CSci 162 Lecture 7 Martin van Bommel. Random Numbers Until now, all programs have behaved deterministically - completely predictable and repeatable based.
LECTURE 07: CLASSIFICATION PT. 3 February 15, 2016 SDS 293 Machine Learning.
Chapter 6 Large Random Samples Weiqi Luo ( 骆伟祺 ) School of Data & Computer Science Sun Yat-Sen University :
Excursions in Modern Mathematics, 7e: Copyright © 2010 Pearson Education, Inc. 16 Mathematics of Normal Distributions 16.1Approximately Normal.
Aim: What is the importance of probability?. What is the language of Probability? “Random” is a description of a kind of order that emerges in the long.
3/7/20161 Now it’s time to look at… Discrete Probability.
Stats 242.3(02) Statistical Theory and Methodology.
AP STATISTICS LESSON THE IDEA OF PROBABILITY.
The Binomial and Normal distributions. Mathematical models Different applications of probability theory can often be recognized as having the same basic.
How selections can be counted with Pascal's Triangle.
PROBABILITY AND COMPUTING RANDOMIZED ALGORITHMS AND PROBABILISTIC ANALYSIS CHAPTER 1 IWAMA and ITO Lab. M1 Sakaidani Hikaru 1.
Now it’s time to look at…
Probabilistic Analysis of Computer Systems
Monte Carlo Methods Some example applications in C++
Lecture Slides Elementary Statistics Eleventh Edition
Binomial and Geometric Random Variables
CHAPTER 14: Binomial Distributions*
Top Changwatchai 18 October 2000
Applied Discrete Mathematics Week 7: Probability Theory
Random Numbers Until now, all programs have behaved deterministically - completely predictable and repeatable based on input values Some applications.
Conditional Probability
Chapter Randomness, Probability, and Simulation
Chapter 5 Sampling Distributions
Chapter 5 Sampling Distributions
Chapter 5 Sampling Distributions
Random numbers Taken from notes by Dr. Neil Moore
CS190/295 Programming in Python for Life Sciences: Lecture 1
Status for AP Congrats! We are done with Part II of the Topic Outline for AP Statistics! (10%-15%) of the AP Test can be expected to cover topics from.
Set, Combinatorics, Probability & Number Theory
Random Number Generation
Sampling Distribution Models
Advanced Placement Statistics Section 7.2: Means & Variance of a
Chapter 5 Sampling Distributions
COUNTING AND PROBABILITY
Now it’s time to look at…
Data Analysis and Statistical Software I ( ) Quarter: Autumn 02/03
Chapter 6: Random Variables
Chapter 5 Sampling Distributions
Random number generators
Now it’s time to look at…
Now it’s time to look at…
CS 144 Advanced C++ Programming January 31 Class Meeting
Randomness, Probability, and Simulation
TEST FOR RANDOMNESS: THE RUNS TEST
Independence and Counting
Mathematical Foundations of BME Reza Shadmehr
Independence and Counting
Independence and Counting
Concepts of Computation
Chapter 11 Probability.
Presentation transcript:

Mathematics 202 Linear Algebra and Probability Spring 2011 Professor Allan B. Cruse Mathematics and Computer Science

Outline for today ● A few administrative preliminaries – textbooks, office hours, website, syllabus, etc. ● Two famous mathematical principles – The Pigeonhole Principle ● Two subjects in the same course ● 16 chapters in 15 weeks ● Maximum cycle-size in an RNG – The Law of Large Numbers ● A simple coin-tossing example ● Some computer simulations ● Linear Congruential Generators

Seymour Lipschutz and Marc Lipson, Probability (2 nd Edition), Schaum's Outline Series: McGraw-Hill (2000) ISBN Seymour Lipschutz and Marc Lipson, Linear Algebra (4th Edition), Schaum's Outline Series: McGraw-Hill (2009) ISBN textbooks

Instructor contact-information Office hours: Room HRN-222A Mon-Wed 1:15-2:00pm, Fri 12:00-12:45pm Campus phone: (415) 422-xxxx website:

Pigeonhole Principle This rule of mathematics says simply that if m objects are distributed among n pigeonholes, where m > n, then some pigeonhole has to contain more than one object

A non-obvious consequence In any group of two or more people (e.g., the group of people in this classroom), there must be two people who are acquainted with exactly the same number of others A proof is obtained by considering two cases, but each case uses the pigeonhole principle

E A B CD BAE, CD Only 4 pigeonholes can be occupied Case 1: Someone knows everyone else must be empty Pigeonhole proof (part 1)

A, BCD, E Only 4 pigeonholes can be occupied Case 2: No one knows everyone else E A B CD must be empty Pigeonhole proof (part 2)

Why bring this up? ● Our Probability text has 7 chapters to cover ● Our Linear Algebra text has 9 chapter to cover ● So the total number of chapters to cover is 16 ● But our course only runs for 15 weeks ● So... according to the pigeonhole principle... we will have to cover 2 chapters in one week!

This week's schedule ● Let's cover the two easiest chapters during our first week, then one chapter per week afterward ● Our first 'weekly quiz' will be this Friday Probability ● It will ask some questions very similar, but not identical, to the worked out problems you'll see at the ends of Chapter 1 and Chapter 2 in our Probability textbook ● If you've understood those problems, you'll be ready for this short Quiz

When an experiment that has more than one possible outcome is repeated a larger and larger number of times, under identical conditions, the fraction of outcomes which are deemed 'successes' will be observed to approach a limiting value which is equal to the probability of a successful outcome on any individual performance of that experiment Law of Large Numbers

When a coin is tossed, two outcomes are possible: “Heads” or “Tails” Assuming the coin's faces are evenly balanced, these two outcomes are equally likely to occur Assuming the coin is randomly tossed, the outcome won't be predictable in advance -- but the accumulation of results from repeated tosses can be observed to follow a predictable pattern! An example

Computer 'simulation' We can use our knowledge of a high-level programming language, such as Python, to create a computer program that will simulate performing a large number of coin-tosses in a short amount of time

'pseudo-random' numbers import random # randomly generate an integer from 0 to 1 x = random.randint(0, 1) # output the result of our simulated coin-toss if ( x > 0 ): print “ Heads “ else: print “ Tails “

Adding some special effects... We can use a few other Python functions to improve the illusion of tossing a coin time.sleep( seconds ) sys.stdout.flush() ______________________________________ tosscoin.py See our 'tosscoin.py' demo-function

Our 'lawlarge.py' demo Using a succession of coin-tossing 'simulations' we can illustrate the LAW OF LARGE NUMBERS in a very short Python program... but we should leave out the 'special effects' in order to speed up the overall demonstration (e.g., one hundred thousand coin-tosses)

Sample output

How does an RNG work? This is actually quite a deep topic, and not really within the scope of this course But one of the earliest and most widely used schemes for computer generation of pseudorandom numbers is related to an idea from Linear Algebra It's called the “Linear Congruential Method”

Recall the straight-line equation y = ax + b multiplierincrement 'a' is the multiplier, 'b' is the increment The method also uses two other parameters: modulusseed 'm' is the modulus, 's' is the seed

lincong.cpp Our 'lincong.cpp' demo unsigned inta = ;// “multiplier” unsigned intb = ;// “increment” unsigned intm = (1 << 24);// “modulus” unsigned ints = 0;// “seed” randomint unsigned int randomint( void ) { static unsigned intx = s; x = (a * x + b) % m; return(x >> 8); }

Why 'pseudo' random? randomint Because the sequence of values returned by successive calls to this 'randomint()' function depends upon the constants a, b, m, and s, and because the number of bits used in the computer to store an 'unsigned int' is finite, the pigeonhole principle guarantees that the same sequence of values will eventually repeat itself in an endless cycle, which therefore becomes “predictible” rather than truly “random”

Discussion questions Can you suggest how to modify our 'tosscoin.py' demo- program so that it will produce a simulation of tossing an 'unfair' coin? Can you propose code for a 'throwdie.py' demo?