Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Mathematics 202 Linear Algebra and Probability Spring 2011 Professor Allan B. Cruse Mathematics and Computer Science."— Presentation transcript:

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

2 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

3 Seymour Lipschutz and Marc Lipson, Probability (2 nd Edition), Schaum's Outline Series: McGraw-Hill (2000) ISBN 987-0-07-135203-1 Seymour Lipschutz and Marc Lipson, Linear Algebra (4th Edition), Schaum's Outline Series: McGraw-Hill (2009) ISBN 978-0-07-154352-1 textbooks

4 Instructor contact-information Office hours: Room HRN-222A Mon-Wed 1:15-2:00pm, Fri 12:00-12:45pm Email: cruse@usfca.educruse@usfca.edu Campus phone: (415) 422-xxxx website:

5 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

6 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

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

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

9 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!

10 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

11 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

12 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

13 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

14 '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 “

15 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

16 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)

17 Sample output

18 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”

19 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

20 lincong.cpp Our 'lincong.cpp' demo unsigned inta = 1664525;// “multiplier” unsigned intb = 1013904223;// “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); }

21 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”

22 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?


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

Similar presentations


Ads by Google