Spatial Statistics and Spatial Knowledge Discovery First law of geography [Tobler]: Everything is related to everything, but nearby things are more related.

Slides:



Advertisements
Similar presentations
4/16/2015 MATH 224 – Discrete Mathematics Counting Basic counting techniques are important in many aspects of computer science. For example, consider the.
Advertisements

1 Section 4.3 Permutations & Combinations. 2 Permutation Set of distinct objects in an ordered arrangement An ordered arrangement of r members of a set.
Permutations and Combinations Rosen 4.3. Permutations A permutation of a set of distinct objects is an ordered arrangement these objects. An ordered arrangement.
Counting Chapter 6 With Question/Answer Animations.
CSCE 2100: Computing Foundations 1 Combinatorics Tamara Schneider Summer 2013.
Counting and Probability The outcome of a random process is sure to occur, but impossible to predict. Examples: fair coin tossing, rolling a pair of dice,
Counting Tools ● Enumeration ● Multiplication ● Addition ● Negation.
CSE115/ENGR160 Discrete Mathematics 04/17/12
Permutations r-permutation (AKA “ordered r-selection”) An ordered arrangement of r elements of a set of n distinct elements. permutation of a set of n.
Lecture 5 Counting 4.3, Permutations r-permutation: An ordered arrangement of r elements of a set of n distinct elements. Example: S={1,2,3}:
CSE 321 Discrete Structures Winter 2008 Lecture 16 Counting.
Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS Fall 2010 Lecture 8Sept. 16,
Discrete Mathematics Lecture 6 Alexander Bukharovich New York University.
Recursive Definitions Rosen, 3.4 Recursive (or inductive) Definitions Sometimes easier to define an object in terms of itself. This process is called.
Computing Fundamentals 2 Lecture 5 Combinatorial Analysis Lecturer: Patrick Browne Based on Chapter 16. A Logical approach.
1 Permutations and Combinations CS/APMA 202 Epp section 6.4 Aaron Bloomfield.
How many ways are there to pass through city A where the arrows represent one-way streets? Answer: mn ways The counting principal: Suppose two experiments.
4. Counting 4.1 The Basic of Counting Basic Counting Principles Example 1 suppose that either a member of the faculty or a student in the department is.
Section 2: The Multiplication Rule Consider the game of tossing a coin, then rolling a die, then picking a card. One possible event would be (H, 2, 2clubs).
Exam 1 Review 5.1, , 8.1, 8.2.
Combinatorics 3/15 and 3/ Counting A restaurant offers the following menu: Main CourseVegetablesBeverage BeefPotatoesMilk HamGreen BeansCoffee.
Rev.S08 MAC 1140 Module 12 Introduction to Sequences, Counting, The Binomial Theorem, and Mathematical Induction.
Copyright © Cengage Learning. All rights reserved. CHAPTER 9 COUNTING AND PROBABILITY.
Counting. Why counting  Determine the complexity of algorithms To sort n numbers, how many instructions are executed ?  Count the number of objects.
Introduction to Counting Discrete Structures. A Multiplication Principle.
Counting. Techniques for counting Rule 1 Suppose we carry out have a sets A 1, A 2, A 3, … and that any pair are mutually exclusive (i.e. A 1  A 2 =
Chapter The Basics of Counting 5.2 The Pigeonhole Principle
Topics to be covered: Produce all combinations and permutations of sets. Calculate the number of combinations and permutations of sets of m items taken.
Generalized Permutations and Combinations
Number of Elements in a Finite Set. Notation : The number of the elements of the set A will be denoted by n(A) Examples (1): Let: Let: A = {a,b,c,d} B.
Chapter 6 With Question/Answer Animations 1. Chapter Summary The Basics of Counting The Pigeonhole Principle Permutations and Combinations Binomial Coefficients.
Permutations and Combinations
Fall 2002CMSC Discrete Structures1 One, two, three, we’re… Counting.
Chapter 3 Permutations and combinations
March 10, 2015Applied Discrete Mathematics Week 6: Counting 1 Permutations and Combinations How many different sets of 3 people can we pick from a group.
Dr. Eng. Farag Elnagahy Office Phone: King ABDUL AZIZ University Faculty Of Computing and Information Technology CPCS 222.
Lecture 5 Counting 4.3, Permutations r-permutation: An ordered arrangement of r elements of a set of n distinct elements. Example: S={1,2,3}:
1 Binomial Coefficients CS 202 Epp, section ??? Aaron Bloomfield.
Simple Arrangements & Selections. Combinations & Permutations A permutation of n distinct objects is an arrangement, or ordering, of the n objects. An.
4.1.2 Pigeonhole principle:Strong Form  Theorem 4.2: Let q 1,q 2,…,q n be positive integers. If q 1 +q 2 +…+q n -n+1 objects are put into n boxes, then.
Counting CSC-2259 Discrete Structures Konstantin Busch - LSU1.
R. Johnsonbaugh Discrete Mathematics 5 th edition, 2001 Chapter 4 Counting methods and the pigeonhole principle.
At the tip of Pascal's Triangle is the number 1, which makes up the zeroth row. The first row (1 & 1) contains two 1's, both formed by adding the.
The Pigeonhole Principle. The pigeonhole principle Suppose a flock of pigeons fly into a set of pigeonholes to roost If there are more pigeons than pigeonholes,
Counting Principles Multiplication rule Permutations Combinations.
Copyright © Ed2Net Learning Inc.1. 2 Warm Up Tell whether each event is dependent or independent 1. Selecting a name from a Chicago telephone book and.
1 CS 140 Discrete Mathematics Combinatorics And Review Notes.
© 2010 Pearson Prentice Hall. All rights reserved. CHAPTER 11 Counting Methods and Probability Theory.
CS Lecture 8 Developing Your Counting Muscles.
2/24/20161 One, two, three, we’re… Counting. 2/24/20162 Basic Counting Principles Counting problems are of the following kind: “How many different 8-letter.
Copyright © Peter Cappello 2011 Simple Arrangements & Selections.
L14: Permutations, Combinations and Some Review EECS 203: Discrete Mathematics.
Section The Pigeonhole Principle If a flock of 20 pigeons roosts in a set of 19 pigeonholes, one of the pigeonholes must have more than 1 pigeon.
Copyright © Cengage Learning. All rights reserved. Probability and Statistics.
Discrete Mathematics and Its Applications Sixth Edition By Kenneth Rosen Chapter 5 Counting 歐亞書局.
Section The Product Rule  Example: How many different license plates can be made if each plate contains a sequence of three uppercase English letters.
COUNTING Discrete Math Team KS MATEMATIKA DISKRIT (DISCRETE MATHEMATICS ) 1.
The Multiplication Rule
Chapter 10 Counting Methods.
L14: Permutations, Combinations and Some Review
The Pigeonhole Principle
Developing Your Counting Muscles
CSE15 Discrete Mathematics 04/19/17
Counting Methods and Probability Theory
COCS DISCRETE STRUCTURES
Copyright © Cengage Learning. All rights reserved.
CS100: Discrete structures
Permutations and Combinations
Counting techniques Basic Counting Principles, Pigeonhole Principle, Permutations and Combinations.
Counting Methods and Probability Theory
Presentation transcript:

Spatial Statistics and Spatial Knowledge Discovery First law of geography [Tobler]: Everything is related to everything, but nearby things are more related than distant things. Drowning in Data yet Starving for Knowledge [Naisbitt -Rogers] Lecture 2 : Basic Statistics with R Pat Browne

Combinatorial Analysis Counting Permutations: the order does matter Combinations: the order doesn't matter The Pigeonhole Principle Examples

Combinatorial Analysis Combinatorial analysis deals with permutations of a set or bag and combinations of a set, which lead to binomial coefficients and the Binomial Theorem.

Rules of Counting Rule of sums: The size of the union on n finite pair wise disjoint sets is the sum of their sizes. Rule of product (a.k.a. the fundamental principle of counting): The size of the cross product of n sets is the product of their sizes. Rule of difference: The size of a set with a subset removed is the size of the set minus the size of the subset.

Product Rule Example If each license plate contains 3 letters and 2 digits. How many unique licenses could there be? Using the rule of products. 26  26  26  10  10 = 1,757,600

All Permutation of a set A permutation of a set of elements is a linear ordering (or sequence) of the elements e.g. {1,4,5} Example Permutation 1 : 1, 4, 5 Example Permutation 2 : 1, 5, 4 An anagram is a permutation of words. There are n  (n – 1)  (n - 2).. 1 permutations of a set of n elements. This is factorial n, written n!

All Permutation of a set There are: n  (n – 1)  (n - 2).. 1 permutations of a set of n elements. Calculated using factorial n, written n! In R this is written factorial(3) In R we can calculate the number of 2- permutations from 4 items as: factorial(4)/factorial(4-2)

Some Permutation of a set More generally permutation of size r from a set of size n. (16.4) P(n,r) = n!/(n-r)! The number of 2 permutations of BYTE is P(4,2) = 4!/(4-2)! = 4  3 = 12 BY,BT,BE,YB,YT,YE,TB,TY,TE,EB,EY,ET P(n,0) = 1 P(n,n-1) = P(n,n) = n! P(n,1) = n Order matters

3-permuations of set Calculate the number of 3-permutations of the word HAND. There are 4 objects and taking 3 at a time. 4Pick3 = 4! / (4-3)! = 4! / 1! = 24 / 1 = 24. Would you consider HDA and HAD as equivalent permutations? They are not equivalent, because each permutation is a sequence, hence and are considered distinct and both are included in the permutation.

r-Permutation with repetition of a set An r-permutations is a permutation that allows repetition. Here are all the 2-permutation of the letters in SON: SS,SO,SN,OS,OO,ON,NS,NO,NN. Given a set of size n, in constructing an r- permutation with repetition, for each element we have n choices. (16.6) The number of r permutations with repetition of a set of size n is n r. Note, repetition is allowed in the permutation but does not occur in the original set.

r-Permutation with repetition of a set (16.6) The number of r permutations with repetition of a set of size n is: n r repetition is allowed in the permutation but not in the original set, because it is a set.

Permutation of a bag A bag may have duplicate elements. Transposition of equal (or duplicate) elements in a permutation does not yield a different permutation e.g. AA=AA. Hence, there will be fewer permutations of a bag than a set of the same size. The permutations on the set {S,O,N} and the bag  M,O,M  are: {S,O,N} = SON,SNO,OSN,ONS,NSO,NOS  M,O,M  = MOM,MMO,OMM

Permutation of a bag: General Rule (16.7) The number of permutations of a bag of size n with k distinct elements occurring n 1, n 2, n 3,.. n k times is: n! n 1 !  n 2 !  n 3 !...  n k !

Calculating permutation of a set and a bag In R calc. number of 3-perms of set {S,O,N} factorial(3) R calc. number of 3-perms of bag  M,O,M  factorial(3) / (factorial(1) * factorial(2)) O occurs once, M twice, gives 3

Permutation of a bag Consider the permutation of the 11 letters of MISSISSIPPI. M occurs 1 time, I occurs 4 times, S occurs 4 times, and P occurs 2 times. Calculate this in R as follows: factorial(11)/(factorial(4)*factorial(4)*factorial(2)) Test the following in R: factorial(0) == factorial(1)

Permutation of a bag  O  a single permutation  M 1,O, M 2 , label the two copies of M. If we choose to distinguish the Ms we get. M 1 M 2 O,M 2 M 1 O,M 1 OM 2,M 2 OM 1,OM 1 M 2,OM 2 M 1 If we do not distinguish the Ms we get  M,O,M  = MOM,MMO,OMM

Permutation of a bag Calculate the number of distinguishable permutations of the word LITTLE. Basic formula is N = total number of letters n i is frequency of each different letter Note double counting of letters T and L, 6!/2!*2!*1!*1!= 720/4 = 180

Permutations in R On previous slides we calculated the number of permutauions. Below we calculate the actual permuations themseves. > install.packages('combinat') > library(combinat) > m <- t(array(unlist(permn(3)), dim = c(3, 6))) # we get 3!=6 permutations > m [,1] [,2] [,3] [1,] [2,] [3,] [4,] [5,] [6,] What does this function do? sample(1:3, 3) Evaluate it 6 times and see. Evaluate permn(3), Evaluate unlist(permn(3))

Permutations in R Alternative way to calculate the actual permuations. > install.packages(“gregmisc”) > library(gregmisc) > length(permutations(n=3,r=2))/2 [1] 6 > permutations(n=3,r=2) [,1] [,2] [1,] 1 2 [2,] 1 3 [3,] 2 1 [4,] 2 3 [5,] 3 1 [6,] 3 2 n Size of the source vector r Size of the target vectors

Combinations of a set An r-combination of a set is a subset of size r. Note the while a permutation is a sequence a combination is a set.

Example: Combinations of a Set An r -combination of a set is a subset of size r. A permutation is a sequence while a combination is a set. The 2-permutations (seq.) of SOHN is:,,,,,,,,,,, The 2-combinations (set) of SOHN is: {S,O},{S,H},{S,N},{O,H},{O,N},{H,N} Note in combinations order is ignored in sets {a,b}={b,a}

Combinations of a Set The binomial coefficient, “n choose r is written”:

Combinations in R install.packages(“combinat”) if not already done There are 15 ways to choose 2 items from 6 items. > choose(6,2) [1] 15 There are zero ways to pick 6 items from 2 items. > choose(2,6) [1] 0

Combinations in R # install.packages('combinat') if not already done # Generate all combinations of # the letters a,b,c,d taking 2 at a time. combn(letters[1:4], 2) #Gives [,1] [,2] [,3] [,4] [,5] [,6] [1,] "a" "a" "a" "b" "b" "c" [2,] "b" "c" "d" "c" "d" "d"

Pascal’s Triangle Beginning with row 0 and place (or column) 0, the number 20 appears in row 6, place 3. Using R we can check this. > choose(6,3) [1] 20 Check these on the triangle. > choose(7,4) [1] 35 > choose(7,2) [1] 21

At the tip of Pascal's Triangle is the number 1, which makes up the 0 th row. The first row (1 & 1) contains two 1's, both formed by adding the two numbers above them to the left and the right, in this case 1 and 0 (all numbers outside the Triangle are 0's). Do the same to create the 2 nd row: 0+1=1; 1+1=2; 1+0=1. And the third: 0+1=1; 1+2=3; 2+1=3; 1+0=1. In this way, the rows of the triangle go on infinitely. A number in the triangle can also be found by nCr (n Choose r) where n is the number of the row and r is the element (column) in that row. For example, in row 3, 1 is the 0 th element, 3 is element number 1, the next three is the 2 nd element, and the last 1 is the 3 rd element. chose(6,3). – gives 20

Special Combinations of a Set How would you verify these laws in R?

Calculating combinations using factorial and division

Calculating "n choose k". Cancellation already done for these

Combinations of a Set (16.10) The number of r-combinations of n elements is A student has to answer 6 out of 9 questions on an exam. How many ways can this be done?

Combinations with repetitions of a Set An r-combination with repetitions of a set S of size n is a bag of size r all of whose elements are in S. An r-combination of a set is a subset of that set; an r- combination with repetition of a set is a bag, since its elements need not be distinct.

Combinations with repetitions of a Set For example, the 2-combinations with repetition of SON are the bags:  S,O ,  S,N ,  O,N ,  S,S ,  O, O ,  N,N  On the other hand, the 2-permutations with repetition are the sequences:,,,,,,,, Note SO and OS are distinct permutations

Combinations with repetitions of a Set (16.12) The number of r -combinations with repetition of a set of size n is: Repetitions size Combination size

Combinations with repetitions of a Set Out of 7 people each gets either a burger, a cheese burger, or fish (3 choices). How many different orders are possible? The answer is the number of 7-combinations with repetition of a set of 3 elements.

The Equivalence of three statements (16.13) The following numbers are equal: The number of integer solutions of the equation x 1 +x 2 +x x n =r. The number of r -combinations with repetition of a set of size n. The number of identical ways r identical objects can be distributed among n different containers.

Permutations How many permutations of the letters are there in the following words: LIE: n=3, 3! = 6 BRUIT: n=5, 5! = 120 CALUMMNY: n=7, 7!=5040

Permutations of a bag A coin is tossed 5 times, landing Head or Tails to form an outcome. One possible outcome is HHTTT. How many possible outcomes are there? How many outcomes have one Head? How many outcomes contain at most one Head?

Permutations of a bag How many possible outcomes are there? Rule of product giving 2 5 =32 possible outcomes.

Permutations of a bag How many outcomes have one Head? Permutation of a bag with 1 Head and four Tails.

Permutations of a bag How many outcomes contain at most one Head? One Head No Heads At most one Head = 6 (rule of sums)

Combinations of Set A chairman has to select a committee of 5 from a facility of 25. How many possibilities are there? How many possibilities are there if the chair should be on the committee?

3-permuations of set Calculate the number of 3-combinations of the string ABCDE. Combinations: In each of the 3 letters groups the position does not matter (e.g. ABC, ABD, ABE, ACD, ACE, ADE are distinct but CBA is not because it is considered equivalent to ABC) C(n,r) = n!/(r! * (n-r)!) Formula: C(5,3) = 5!/(3!*(5-3)!) = 5*4*3*2*1/(3*2*1*2*1)) = 5*2 = 10

Calculate the number of combinations of a set of 6 elements Formula: C(n,r) = n!/(r! * (n-r)!) Example: C(6,2) = 6!/(2!*(6-2)!) = 15 In R > choose(6,1) + choose(6,2) + choose(6,3) + choose(6,4) + choose(6,5) + choose(6,6) Gives 63

The Pigeonhole Principle (16.43) If more than n pigeons are placed in n holes, at least one hole will contain more than one pigeon. With more than n pigeons in n holes the average number of pigeons per hole is greater than one. The statement “at least one hole will contain more than one pigeon” is equivalent to “the maximum number of pigeons in any whole is greater than one”.

The Pigeonhole Principle