1 / 30

Harper Langston New York University Summer 2018

This lecture covers topics such as generic functions, one-to-one functions, onto functions, inverse functions, composition of functions, Pigeonhole Principle, cardinality, counting and probability.

richardsj
Télécharger la présentation

Harper Langston New York University Summer 2018

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Harper Langston New York University Summer 2018 Discrete MathematicsLecture 8+Functions, Pigeonhole,Multiplication Rule, Combinations, Probability, etc.

  2. Administration / Q&A • Class Web Site http://cs.nyu.edu/courses/summer18/CSCI-GA.2340-001/ • Mailing ListSubscribe at see website / Classes Messages to: see website / Classes • TA/Office Hours, etc: Homework (in person or on Classes – extra day for Classes)

  3. Generic Functions • A function f: X  Y is a relationship between elements of X to elements of Y, when each element from X is related to a unique element from Y • X is called domain of f, range of f is a subset of Y so that for each element y of this subset there exists an element x from X such that y = f(x) • Sample functions: • f : R  R, f(x) = x2 • f : Z  Z, f(x) = x + 1 • f : Q  Z, f(x) = 2

  4. Generic Functions • Arrow diagrams for functions • Non-functions • Equality of functions: • f(x) = |x| and g(x) = sqrt(x2) • Identity function • Logarithmic function

  5. One-to-One Functions • Function f : X  Y is called one-to-one (injective) when for all elements x1 and x2 from X if f(x1) = f(x2), then x1 = x2 • Determine whether the following functions are one-to-one: • f : R  R, f(x) = 4x – 1 • g : Z  Z, g(n) = n2 • Hash functions

  6. Onto Functions • Function f : X  Y is called onto (surjective) when given any element y from Y, there exists x in X so that f(x) = y • Determine whether the following functions are onto: • f : R  R, f(x) = 4x – 1 • f : Z  Z, g(n) = 4n – 1 • Bijection is one-to-one and onto • Reversing strings function is bijective

  7. Inverse Functions • If f : X  Y is a bijective function, then it is possible to define an inverse function f-1: Y  X so that f-1(y) = x whenever f(x) = y • Find an inverse for the following functions: • String-reverse function • f : R  R, f(x) = 4x – 1 • Inverse function of a bijective function is a bijective function itself

  8. Composition of Functions • Let f : X  Y and g : Y  Z, let range of f be a subset of the domain of g. The we can define a composition of g o f : X  Z • Let f,g : Z  Z, f(n) = n + 1, g(n) = n^2. Find f o g and g o f. Are they equal? • Composition with identity function • Composition with an inverse function • Composition of two one-to-one functions is one-to-one • Composition of two onto functions is onto

  9. Pigeonhole Principle • If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons • A function from one finite set to a smaller finite set cannot be one-to-one • In a group of 13 people must there be at least two who have birthday in the same month? • A drawer contains 10 black and 10 white socks. How many socks need to be picked to ensure that a pair is found? • Let A = {1, 2, 3, 4, 5, 6, 7, 8}. If 5 integers are selected must at least one pair have sum of 9?

  10. Pigeonhole Principle • Generalized Pigeonhole Principle: For any function f : X  Y acting on finite sets, if n(X) > k * N(Y), then there exists some y from Y so that there are at least k + 1 distinct x’s so that f(x) = y • “If n pigeons fly into m pigeonholes, and, for some positive k, m >k*m, then at least one pigeonhole contains k+1 or more pigeons” • In a group of 85 people at least 4 must have the same last initial. • There are 42 students who are to share 12 computers. Each student uses exactly 1 computer and no computer is used by more than 6 students. Show that at least 5 computers are used by 3 or more students.

  11. Cardinality • Cardinality refers to the size of the set • Finite and infinite sets • Two sets have the same cardinality when there is bijective function associating them • Cardinality is is reflexive, symmetric and transitive • Countable sets: set of all integers, set of even numbers, positive rationals (Cantor diagonalization) • Set of real numbers between 0 and 1 has same cardinality as set of all reals • Computability of functions

  12. Counting and Probability • Coin tossing • Random process • Sample space is the set of all possible outcomes of a random process. An event is a subset of a sample space • Probability of an event is the ratio between the number of outcomes that satisfy the event to the total number of possible outcomesP(E) = N(E)/N(S) for event E and sample space S • Rolling a pair of dice and card deck as sample random processes

  13. Possibility Trees • Teams A and B are to play each other repeatedly until one wins two games in a row or a total three games. • What is the probability that five games will be needed to determine the winner? • Suppose there are 4 I/O units and 3 CPUs. In how many ways can I/Os and CPUs be attached to each other when there are no restrictions?

  14. Multiplication Rule • Multiplication rule: if an operation consists of k steps each of which can be performed in ni ways (i = 1, 2, …, k), then the entire operation can be performed in ni ways. • Number of PINs • Number of elements in a Cartesian product • Number of PINs without repetition • Number of Input/Output tables for a circuit with n input signals • Number of iterations in nested loops

  15. Multiplication Rule • Three officers – a president, a treasurer and a secretary are to be chosen from four people: Alice, Bob, Cindy and Dan. Alice cannot be a president, Either Cindy or Dan must be a secretary. How many ways can the officers be chosen?

  16. Permutations • A permutation of a set of objects is an ordering of these objects • The number of permutations of a set of n objects is n! (Examples) • An r-permutation of a set of n elements is an ordered selection of r elements taken from a set of n elements: P(n, r) (Examples) • P(n, r) = n! / (n – r)! • Show that P(n, 2) + P(n, 1) = n2

  17. Addition Rule • If a finite set A is a union of k mutually disjoint sets A1, A2, …, Ak, then n(A) = n(Ai) • Number of words of length no more than 3 • Number of 3-digit integers divisible by 5

  18. Difference Rule • If A is a finite set and B is its subset, then n(A – B) = n(A) – n(B) • How many PINS contain repeated symbols? • So, P(Ac) = 1 – P(A) (Example for PINS) • How many students are needed so that the probability of two of them having the same birthday equals 0.5?

  19. Inclusion/Exclusion Rule • 2 sets • 3 sets • N Sets

  20. Combinations • An r-combination of a set of n elements is a subset of r elements: C(n, r) • Permutation is an ordered selection, combination is an unordered selection • Quantitative relationship between permutations and combinations: P(n, r) = C(n, r) * r! • Permutations of a set with repeated elements • Double counting

  21. Team Selection Problems • There are 12 people, 5 men and 7 women, to work on a project: • How many 5-person teams can be chosen? • If two people insist on working together (or not working at all), how many 5-person teams can be chosen? • If two people insist on not working together, how many 5-person teams can be chosen? • How many 5-person teams consist of 3 men and 2 women? • How many 5-person teams contain at least 1 man? • How many 5-person teams contain at most 1 man?

  22. Poker Problems • What is a probability to contain one pair? • What is a probability to contain two pairs? • What is a probability to contain a triple? • What is a probability to contain royal flush? • What is a probability to contain straight flush? • What is a probability to contain straight? • What is a probability to contain flush? • What is a probability to contain full house?

  23. Combinations with Repetition • An r-combination with repetition allowed is an unordered selection of elements where some elements can be repeated • The number of r-combinations with repetition allowed from a set of n elements is C(r + n –1, r) • Soft drink example

  24. Algebra of Combinations and Pascal’s Triangle • The number of r-combinations from a set of n elements equals the number of (n – r)-combinations from the same set. • Pascal’s triangle: C(n + 1, r) = C(n, r – 1) + C(n, r) • C(n,r) = C(n,n-r)

  25. Probability Axioms • P(Ac) = 1 – P(A) • P(A  B) = P(A) + P(B) – P(A  B) • What if A and B mutually disjoint?(Then P(A  B) = 0)

  26. Conditional Probability • For events A and B in sample space S if P(A) ¹ 0, then the probability of B given A is: P(A | B) = P(A  B)/P(A) • Example with Urn and Balls:- An urn contains 5 blue and

  27. Conditional Probability Example • An urn contains 5 blue and 7 gray balls. 2 are chosen at random.- What is the probability they are blue?- Probability first is not blue but second is?- Probability second ball is blue?- Probability at least one ball is blue?- Probability neither ball is blue?

  28. Conditional Probability Extended • Imagine one urn contains 3 blue and 4 gray balls and a second urn contains 5 blue and 3 gray balls • Choose an urn randomly and then choose a ball. • What is the probability that if the ball is blue that it came from the first urn?

  29. Bayes’ Theorem • Extended version of last example. • If S, our sample space, is the union of n mutually disjoint events, B1, B2, …, Bn and A is an even in S with P(A) ¹ 0 and k is an integer between 1 and n, then:P(Bk | A) = P(A | Bk) * P(Bk) . P(A | B1)*P(B1) + … + P(A | Bn)*P(Bn) Application: Medical Tests (false positives, etc.)

  30. Independent Events • If A and B are independent events, P(A  B) = P(A)*P(B) • If C is also independent of A and B P(A  B  C) = P(A)*P(B)*P(C) • Difference from Conditional Probability can be seen via Russian Roulette example.

More Related