maxbox Starter 10 Start with Statistic Programming 1.1 Find the Probability

Similar documents
Combinations and Permutations

The study of probability is concerned with the likelihood of events occurring. Many situations can be analyzed using a simplified model of probability

Poker: Probabilities of the Various Hands

Math 3012 Applied Combinatorics Lecture 2

Poker: Probabilities of the Various Hands

PROBABILITY. Example 1 The probability of choosing a heart from a deck of cards is given by

Fundamentals of Probability

COUNTING AND PROBABILITY

Counting Methods and Probability

Honors Precalculus Chapter 9 Summary Basic Combinatorics

MAT104: Fundamentals of Mathematics II Summary of Counting Techniques and Probability. Preliminary Concepts, Formulas, and Terminology

November 6, Chapter 8: Probability: The Mathematics of Chance

Permutations and Combinations. Quantitative Aptitude & Business Statistics

Welcome! Worksheet Counting Principal, Permutations, Combinations. Updates: U4T is 12/12

Question 1: How do you count choices using the multiplication principle?

Discrete Structures for Computer Science

Topics to be covered

CS100: DISCRETE STRUCTURES. Lecture 8 Counting - CH6

2. Combinatorics: the systematic study of counting. The Basic Principle of Counting (BPC)

Math 14 Lecture Notes Ch. 3.6

7.1 Chance Surprises, 7.2 Predicting the Future in an Uncertain World, 7.4 Down for the Count

Probability MAT230. Fall Discrete Mathematics. MAT230 (Discrete Math) Probability Fall / 37

In this section, we will learn to. 1. Use the Multiplication Principle for Events. Cheesecake Factory. Outback Steakhouse. P.F. Chang s.

Fundamental Counting Principle

A Lesson in Probability and Statistics: Voyager/Scratch Coin Tossing Simulation

Permutations and Combinations. MATH 107: Finite Mathematics University of Louisville. March 3, 2014

LAMC Junior Circle February 3, Oleg Gleizer. Warm-up

JIGSAW ACTIVITY, TASK # Make sure your answer in written in the correct order. Highest powers of x should come first, down to the lowest powers.

Discrete Mathematics: Logic. Discrete Mathematics: Lecture 15: Counting

6/24/14. The Poker Manipulation. The Counting Principle. MAFS.912.S-IC.1: Understand and evaluate random processes underlying statistical experiments

Course Learning Outcomes for Unit V

Day 1 Counting Techniques

7.4 Permutations and Combinations

W = {Carrie (U)nderwood, Kelly (C)larkson, Chris (D)aughtry, Fantasia (B)arrino, and Clay (A)iken}

Permutations. and. Combinations

DISCRETE STRUCTURES COUNTING

Contents 2.1 Basic Concepts of Probability Methods of Assigning Probabilities Principle of Counting - Permutation and Combination 39

The Product Rule The Product Rule: A procedure can be broken down into a sequence of two tasks. There are n ways to do the first task and n

Problems from 9th edition of Probability and Statistical Inference by Hogg, Tanis and Zimmerman:

WEEK 7 REVIEW. Multiplication Principle (6.3) Combinations and Permutations (6.4) Experiments, Sample Spaces and Events (7.1)

Probability. The MEnTe Program Math Enrichment through Technology. Title V East Los Angeles College

CHAPTER 8 Additional Probability Topics

Permutations And Combinations Questions Answers

5 Elementary Probability Theory

Advanced Intermediate Algebra Chapter 12 Summary INTRO TO PROBABILITY

PERMUTATIONS AND COMBINATIONS

Section 6.1 #16. Question: What is the probability that a five-card poker hand contains a flush, that is, five cards of the same suit?

Introductory Probability

6.4 Permutations and Combinations

How Euler Did It. by Ed Sandifer. Derangements. September, 2004

Probability - Introduction Chapter 3, part 1

Chapter 10A. a) How many labels for Product A are required? Solution: ABC ACB BCA BAC CAB CBA. There are 6 different possible labels.

* Order Matters For Permutations * Section 4.6 Permutations MDM4U Jensen. Part 1: Factorial Investigation

Math 166: Topics in Contemporary Mathematics II

ECON 214 Elements of Statistics for Economists

Counting. Chapter 6. With Question/Answer Animations

CSE 21 Mathematics for Algorithm and System Analysis

TImath.com. Statistics. Too Many Choices!

Chapter 5 - Elementary Probability Theory

Probability. Engr. Jeffrey T. Dellosa.

Unit Nine Precalculus Practice Test Probability & Statistics. Name: Period: Date: NON-CALCULATOR SECTION

Combinatorial Proofs

3 ky. t x 1) 1/3, -1/2 2) = 140 4) 74 units 5) a) 2400 b) $12 c) 96 students. 6) a) y = 1.10x x b) points c) 1984, 2003

Grade 7/8 Math Circles November 8 & 9, Combinatorial Counting

What are the chances?

* Order Matters For Permutations * Section 4.6 Permutations MDM4U Jensen. Part 1: Factorial Investigation

Permutations and Combinations

Permutation and Combination

Such a description is the basis for a probability model. Here is the basic vocabulary we use.

Probability Homework Pack 1

Lecture 1. Permutations and combinations, Pascal s triangle, learning to count

Remember that represents the set of all permutations of {1, 2,... n}

Discrete Mathematics with Applications MATH236

Jessica Fauser EDUC 352 October 21, 2011 Unit Lesson Plan #3. Lesson: Permutations and Combinations Length: 45 minutes Age/Grade Intended: Algebra II

Week 1: Probability models and counting

CS1800: Intro to Probability. Professor Kevin Gold

MATH 13150: Freshman Seminar Unit 4

Counting and Probability Math 2320

Section Summary. Finite Probability Probabilities of Complements and Unions of Events Probabilistic Reasoning

Session 5 Variation About the Mean

Generalized Permutations and The Multinomial Theorem

4.4: The Counting Rules

MATH 2420 Discrete Mathematics Lecture notes

Counting Things Solutions

Organizing and Customizing Content

Strings. A string is a list of symbols in a particular order.

Block 1 - Sets and Basic Combinatorics. Main Topics in Block 1:

elements in S. It can tricky counting up the numbers of

EECS 203 Spring 2016 Lecture 15 Page 1 of 6

Counting Things. Tom Davis March 17, 2006

Intermediate Math Circles November 13, 2013 Counting II

Nwheatleyschaller s The Next Step...Conditional Probability

ABE/ASE Standards Mathematics

1 of 14. Lesson 2 MORE TOOLS, POLYGONS, ROOF. Updated Sept. 15, By Jytte Christrup.

CH 13. Probability and Data Analysis

In this project, you will create a memory game where you have to memorise and repeat a sequence of random colours!

EZ360 User Manual (Oculus Go version)

Name Class Date. Introducing Probability Distributions

Chapter 5: Probability: What are the Chances? Section 5.2 Probability Rules

Math 106 Lecture 3 Probability - Basic Terms Combinatorics and Probability - 1 Odds, Payoffs Rolling a die (virtually)

Transcription:

maxbox Starter 10 Start with Statistic Programming 1.1 Find the Probability Today we spend time in programming with Statistics and in our case with probability. Statistic is a branch of applied mathematics concerned with the collection and interpretation of quantitative data and the use of probability theory to estimate population parameters. A parameter is a numeric measurement that describes some property of the population for example mean or max height of a random sample from a population. In this large field we deal with some basics today called probability. Probability is the study of chance or the likelihood of an event happening. Directly or indirectly, probability plays a role in all activities. For example, we may say that it will probably possible to unlock the lock because most of the combinations are too easy. Our question will be to find out the probability to unlock a lock in 4 cases. All 4 examples discuss a different combination lock within math and security. 1. Permutation = n! 2. Permutation (Variation without repeating) = npr = n!/(n-k)! 3. Combination (binominal coefficient) = ncr = npr / k! 4. Variation (Permutation with repeating) = n^k Permutation means arrangement of things. The word arrangement is used, if the order of things is considered. Combination means selection of things. The word selection is used, when the order of things has no importance. So, in Math we use a more precise language: If the order doesn't matter, it s a Combination. If the order does matter it s a Permutation. Hope you did already work with the Starter 1 to 9 available at: http://www.softwareschule.ch/maxbox.htm

This lesson will introduce you to the probability of an event. The event in our case is to manipulate or hack the lock. If the probability of an event, A, is P(A), then the probability that the event would not occur (also called the complementary event) is 1 P(A). So the P(A) to unlock a lock with 10000 (10^4) possibilities is 1/10000. 1.2 Visualize the Possibilities As you already know the tool is split up into the toolbar across the top, the editor or code part in the centre and the output window at the bottom will show you the 4 cases with all possibilities. Before this starter code will work you will need to download maxbox from the website. It can be down-loaded from http://sourceforge.net/projects/maxbox site. Once the download has finished, unzip the file, making sure that you preserve the folder structure as it is. If you double-click maxbox3.exe the box opens a default program. Make sure the version is at least 3.2 because the number cruncher will need that;). Test it with F9 or press Compile and you should hear a sound first and a browser will open. So far so good now we ll open the example: 212_statisticmodule4.txt If you can t find the file use the link: http://www.softwareschule.ch/download/212_statisticmodule4.txt Or get it as a pdf - document: http://www.softwareschule.ch/download/statisticmodule.pdf Or you use the Save Page as function of your browser 1 and load it from examples (or wherever you stored it). One important thing: You need some time to run the whole simulation, it depends on your CPU power means you have to wait about 30 seconds for a run. Now let s take a look at the code of this project first with the procedures set. Our first line is 08 Program Statistics_Module_4; We have to name the program it s called Statistics_Module_4. Now we jump to line 55: 55 Procedure One_Permutation_4; 56 var 57 i,k,l,m: byte; 58 count: integer; 59 begin 60 count:= 0; 61 for i:= 0 to 3 do 62 for k:= 0 to 3 do 63 for l:= 0 to 3 do 64 for m:= 0 to 3 do begin 1.3 First Case One_Permutation_4 How many different 4-digit numbers can be formed from the digits 0, 1, 2, 3 where digits in each number is found exactly one times, means no repeating. The lock has only 4 numbers with 4 elements, e.g.: 1 2 0 3 1 Or copy & paste 2

The lock has a four number code consisting of four digits without repeating. How many possible code combinations are there in the Procedure on line 55? Possible outcomes are the numbers 0, 1, 2, 3 and sample space, S = {0, 1, 2, 3}. So, your first choice would have 4 possibilities, and your next choice would then have 3 possibilities, then 2, 1. And the total permutations would be: 4 3 2 1 = 24 The above expression 4 3 2 1 = can be written as 4!, which is read as six factorial. In general, N! is the product of all the counting numbers beginning with n and counting backwards to 1. We define 0! to be simply as 1. Our first lock looks like a normal lock but it has only 4 numbers [0..3] to set and you can t set a number twice in one line, so 4114 is impossible anyway! The maximum security would be 10! With the numbers {0..9} and with 10 elements built on the lock. 1.4 Second Case Two_Permutation_4_of_10 The second case is more realistic, you can set 10 numbers {0..9} but also again no repeating of the numbers in one line (or row), for e.g.:. 1 2 8 9 80 Procedure Two_Permutation_4_of_10; 81 var 82 i,k,l,m: byte; 83 count: integer; 84 begin 85 count:= 0; 86 for i:= 0 to 9 do 87 for k:= 0 to 9 do 88 for l:= 0 to 9 do 89 for m:= 0 to 9 do begin Once the range from 0 to 9 is set, your application shows all the permutations in the output window, but how many are there? Our "order of 4 out of 10 numbers example" would be: 10! / (10-4)! = 5040 This example requires 5 local variables and a filter to avoid repetition. Instead of writing the whole formula: npr = n!/(n-k)!, people use different notations such as these: 3

So you can build your own lock depends on the brain memory you have to find out a 7 digit code;) for example the lock has a 7 character code with 40 numbers and characters of the readable ASCII-Code: 40! / (40-7)! = 9.3963 E+10 So the maximum range on Delphi depends on your operating system types, means nowadays an int64 range is the max big int. With a Big Integer Library (bigintlib) you'll see the full range of Fact(40): 815915283247897734345611269596115894272000000000 Another way is to use the type extended, but the limitation is precision like Writeln(FloatToStr(Fact(40))) You can test this Big Int Library with the script: 161_bigint_class.txt 1.5 Third Case Three_Combination_without_Order_4_of_20 Next is a really amazing thing, you ll see the first real digital lock just with the numbers of 0 and 1 and a hardware lock with 20 elements on it! 0 0 0 1 0 0 1 1 0 0 0 0 0 1 0 0 0 0 0 0 It s a really long lock but thin, cause only 0 and 1 can be set. An arrangement of numbers in which the order is not important is called a combination. This is different from permutation where the order matters. For example, suppose we are arranging the letters A, B and C. In a permutation, the arrangement ABC and ACB are different. But, in a combination, the arrangements ABC and ACB are the same because the order is not important. Those are the so called binominal coefficients and on a calculator you find the ncr() button for example 4 of 20 = 4845 = NCR(20,4) or a lotto 4 of 20. Yes you may know this formula to compute all lotto combinations you had to mark a cross! The number of combinations of n things taken r at a time is written as C(n, r). So the normal case is no repetition: such as lottery numbers (2,14,15,27,30,33) The question now is the possible outcome in our lock. That formula is so important it is often just written in big parentheses like this: The result of ncr(20,4) = 4845 and the probability to hack the code is 1/4845. 116 for i:= 0 to 1 do 117 for k:= 0 to 1 do 118 for l:= 0 to 1 do 119 for m:= 0 to 1 do // 20 times You can also use Pascal's Triangle to find the values. Go down to row "n" (the top row is 0), and then along "r" places and the value there is your answer. Here is an extract showing row 16: 1 14 91 364... 1 15 105 455 1365... 1 16 120 560 1820 4368... 4

And that s how to compute the output for each case in line 138: 138 Writeln(Format('Case: %d - %d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d', If you re interested in the Pascal Triangle, here s the script: 172_pascal_triangleform2.TXT [count,i,k,l,m,n,o,p,q,r,s,t,u,v,w,q1,r1,s1,t1,u1,v1])); I got in this case a combination with 20 elements with a code combination of 4845 codes so you can compare this combination with the case 3 which has 5040 possible codes. You can really see a pattern in the output too: Case: 4829-11100000000000000001 Case: 4830-11100000000000000010 Case: 4831-11100000000000000100 Case: 4832-11100000000000001000 Case: 4833-11100000000000010000 Case: 4834-11100000000000100000 Case: 4835-11100000000001000000 Case: 4836-11100000000010000000 Case: 4837-11100000000100000000 Case: 4838-11100000001000000000 Case: 4839-11100000010000000000 Case: 4840-11100000100000000000 Case: 4841-11100001000000000000 Case: 4842-11100010000000000000 Case: 4843-11100100000000000000 Case: 4844-11101000000000000000 Case: 4845-11110000000000000000 1.6 Forth Case Four_Variation_Lock_4 So the last one is the easiest one to calculate and the normal case everywhere, it s also called permutations with repetition or simply variation: 1 1 1 2 When you have n things to choose from... you have n choices each time! When choosing r of them, the permutations are: n n... (r times) = n r 156 for i:= 0 to 9 do 157 for k:= 0 to 9 do 158 for l:= 0 to 9 do 159 for m:= 0 to 9 do begin 5

It s almost the same like case 2 but without a filter so the numbers can repeat in one line. 1: The Simulation of the four Cases And once again you can also use the functions of your calculator npr and ncr. As well as the "big parentheses" in a combination, people also use different notations. Permutation or Combination Using combination think of a lotto game or a digital lock. It s also interesting to note how this formula of combination is nice and symmetrical: Probability theory is required to describe nature.[19] A revolutionary discovery of early 20th century physics was the random character of all physical processes that occur at sub-atomic scales and are governed by the laws of quantum mechanics. The objective wave function evolves deterministically but, according to the Copenhagen interpretation, randomness is explained by a wave function collapse when an observation is made. However, the loss of determinism for the sake of instrumentalism did not meet with universal approval. Albert Einstein famously remarked in a letter to Max Born: "I am convinced that God does not play dice".[20] (http://en.wikipedia.org/wiki/probability) But knowing how these formulas work is only half the battle. Figuring out how to interpret a real world situation can be quite hard. But at least now you know how to calculate all 4 cases. 6

Task: Try to change the Output in the procedure One_Permutation_4 with numbers from 1 to 4 in order to avoid the 0. Experiment: Picking a card: In an experiment, a card is picked from a stack of six cards, which spells the word PASCAL. Possible outcomes are P, A 1, S, C, A 2 and L. Sample space, S = {P, A 1, S, C, A 2 L}. There are 2 cards with the letter A why and what for? 1.7 Conclusion Let s consider in the end the 4 cases in comparison with a lock and his elements: 1. Permutation = n! Num. [0..3], 4 Elements, Calculation 4!=24 1 2 0 3 2. Permutation (Variation without repeating) Num. [0..9], 4 Elements, Calculation npr(10,4) = 5040 1 2 8 9 3. Combination = ncr = npr / k! Num. [0..1] 20 Elements, Calculation npr / k! = 4845 0 0 0 1 0 0 1 1 0 0 0 0 0 1 0 0 0 0 0 0 4. Variation (repeating) = n^k Num. [0..9] 4 Elements, Calculation n^k=10^4=10000 1 1 1 2 max@kleiner.com Links of maxbox and an Article of Big Numbers: http://www.softwareschule.ch/maxbox.htm http://sourceforge.net/projects/maxbox http://sourceforge.net/apps/mediawiki/maxbox/ http://www.delphi3000.com/articles/article_6712.asp?sk= Reward 2010 - Algorithm of the Year 2010 solves all Lotto Combinations also with Compiler! http://www.softwareschule.ch/download/97_pas_lottocombinations_beat_plus.pdf http://www.softwareschule.ch/download/maxbox97_lottoproject_allcombinations_dpr.txt # 19 Burgi, Mark. Interpretations of Negative Probabilities. 2009, p. 1. # 20 Jedenfalls bin ich überzeugt, daß der Alte nicht würfelt. 7