Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Slides:



Advertisements
Similar presentations
AP Statistics Section 6.2C Independent Events & The Multiplication Rule.
Advertisements

Review of Probability. Definitions (1) Quiz 1.Let’s say I have a random variable X for a coin, with event space {H, T}. If the probability P(X=H) is.
Copyright © 2006 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Section 5.1 and 5.2 Probability
1 Counting. 2 Situations where counting techniques are used  You toss a pair of dice in a casino game. You win if the numbers showing face up have a.
Chapter 5 Probability Distributions. E.g., X is the number of heads obtained in 3 tosses of a coin. [X=0] = {TTT} [X=1] = {HTT, THT, TTH} [X=2] = {HHT,
8.7 Probability. Ex 1 Find the sample space for each of the following. One coin is tossed. Two coins are tossed. Three coins are tossed.
1 Chapter 6: Probability— The Study of Randomness 6.1The Idea of Probability 6.2Probability Models 6.3General Probability Rules.
Introduction to Probability
1 Introduction to Stochastic Models GSLM Outline  course outline course outline  Chapter 1 of the textbook.
Chapter 4 Using Probability and Probability Distributions
Median/Order Statistics Algorithms
CS38 Introduction to Algorithms Lecture 7 April 22, 2014.
Administrative Sep. 20 (today) – HW1 due Sep. 21 8am – problem session Sep. 25 – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct.
CSC 282 – Algorithms Daniel Stefankovic – CSB 620 TA: Girts Folkmanis – CSB 614
Probabilistic (Average-Case) Analysis and Randomized Algorithms Two different but similar analyses –Probabilistic analysis of a deterministic algorithm.
Analysis of Algorithms CS 477/677 Instructor: Monica Nicolescu.
Administrative Sep. 27 (today) – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages of DPV)
Chris Morgan, MATH G160 January 18, 2012 Lecture 4 Chapter 4.4: Independence 1.
Probability Concepts and Applications
Qsort - 1 Lin / Devi Comp 122 d(n)d(n) Today’s puzzle  How far can you reach with a stack of n blocks, each 2 units long?
Quicksort!. A practical sorting algorithm Quicksort  Very efficient Tight code Good cache performance Sort in place  Easy to implement  Used in older.
Finite probability space set  (sample space) function P:  R + (probability distribution)  P(x) = 1 x 
Section 4.3 The Addition Rules for Probability
Fundamentals of Probability
Lectures prepared by: Elchanan Mossel Yelena Shvets Introduction to probability Stat 134 FAll 2005 Berkeley Follows Jim Pitman’s book: Probability Section.
Sets, Combinatorics, Probability, and Number Theory Mathematical Structures for Computer Science Chapter 3 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesProbability.
Sets, Combinatorics, Probability, and Number Theory Mathematical Structures for Computer Science Chapter 3 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesProbability.
Great Theoretical Ideas In Computer Science Steven Rudich, Anupam GuptaCS Spring 2004 Lecture 22April 1, 2004Carnegie Mellon University
Chapter 8 Probability Section R Review. 2 Barnett/Ziegler/Byleen Finite Mathematics 12e Review for Chapter 8 Important Terms, Symbols, Concepts  8.1.
Warm-Up 1. What is Benford’s Law?
Great Theoretical Ideas in Computer Science.
 Review Homework Chapter 6: 1, 2, 3, 4, 13 Chapter 7 - 2, 5, 11  Probability  Control charts for attributes  Week 13 Assignment Read Chapter 10: “Reliability”
Lesson 6 – 2b Probability Models Part II. Knowledge Objectives Explain what is meant by random phenomenon. Explain what it means to say that the idea.
CS433 Modeling and Simulation Lecture 03 – Part 01 Probability Review 1 Dr. Anis Koubâa Al-Imam Mohammad Ibn Saud University
COMPSCI 102 Introduction to Discrete Mathematics.
PROBABILITY, PROBABILITY RULES, AND CONDITIONAL PROBABILITY
5.1 Randomness  The Language of Probability  Thinking about Randomness  The Uses of Probability 1.
Probability Prof. Richard Beigel Math C067 September 27, 2006.
Math I.  Probability is the chance that something will happen.  Probability is most often expressed as a fraction, a decimal, a percent, or can also.
Analysis of Algorithms CS 477/677 Instructor: Monica Nicolescu Lecture 7.
Probability Basics Section Starter Roll two dice and record the sum shown. Repeat until you have done 20 rolls. Write a list of all the possible.
Sixth lecture Concepts of Probabilities. Random Experiment Can be repeated (theoretically) an infinite number of times Has a well-defined set of possible.
QR 32 Section #6 November 03, 2008 TA: Victoria Liublinska
1 Probability: Introduction Definitions,Definitions, Laws of ProbabilityLaws of Probability Random VariablesRandom Variables DistributionsDistributions.
Week 21 Rules of Probability for all Corollary: The probability of the union of any two events A and B is Proof: … If then, Proof:
Great Theoretical Ideas in Computer Science for Some.
Great Theoretical Ideas In Computer Science John LaffertyCS Fall 2006 Lecture 10 Sept. 28, 2006Carnegie Mellon University Classics.
Probability and Simulation The Study of Randomness.
Theory of Computational Complexity Probability and Computing Ryosuke Sasanuma Iwama and Ito lab M1.
Probability What is the probability of rolling “snake eyes” in one roll? What is the probability of rolling “yahtzee” in one roll?
Great Theoretical Ideas in Computer Science.
Conditional Probability 423/what-is-your-favorite-data-analysis-cartoon 1.
Chapter 7. Section 7.1 Finite probability  In a lottery, players win a large prize when they pick four digits that match, in the correct order, four.
Section 5.1 and 5.2 Probability
Mathematics Department
ICS 253: Discrete Structures I
Chapter 4 Probability Concepts
Chapter 6 6.1/6.2 Probability Probability is the branch of mathematics that describes the pattern of chance outcomes.
PROBABILITY AND PROBABILITY RULES
PROBABILITY.
What is Probability? Quantification of uncertainty.
CS104:Discrete Structures
Multiplication Rule and Conditional Probability
CSCI 5832 Natural Language Processing
Great Theoretical Ideas In Computer Science
Great Theoretical Ideas In Computer Science
I flip a coin two times. What is the sample space?
Mutually Exclusive Events
Sets, Combinatorics, Probability, and Number Theory
Presentation transcript:

Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages of DPV)

Administrative You may work with one other person on homeworks, but you must each write up your solutions separately (without any written aid). If you work with another person, indicate who you worked with on your solution (thus you should each indicate each other). Homework rules: All cases of suspected dishonesty must be reported to the Board, either through a shortform resolution or by forwarding a case to the Board for a hearing. Faculty may not come to an understanding with a student on their own in a case of suspected dishonesty, but must use the short form resolution or submit a case. University Academic Honesty Policy:

Recurrences T(n) = a T(n/b) + f(n) If f(n) = O(n c-  ) then T(n) =  (n c ) If f(n) =  (n c ) then T(n) =  (n c.log n) If f(n) =  (n c+  ) then T(n)=  (f(n)) if a.f(n/b)  d.f(n) for some d n 0 c=log b a T(n) = 3 T(n/2) +  (n) T(n) =  (n log 3 ) T(n) = 2T(n/2) +  (n) T(n) =  (n.log n) 2

Finding the k-th smallest element k =  n/2  = MEDIAN Split(A[1..n],x) xx xx runs in time O(n)

Finding the k-th smallest element k =  n/2  = MEDIAN Split(A[1..n],x) xx xx j j  k  k-th smallest on left j<k  (k-j)-th smallest on right

Finding the k-th smallest element

) sort each 5-tuple

Finding the k-th smallest element ) sort each 5-tuple

Finding the k-th smallest element ) sort each 5-tuple

Finding the k-th smallest element ) sort each 5-tuple

Finding the k-th smallest element ) sort each 5-tuple

Finding the k-th smallest element ) sort each 5-tuple TIME = ?

Finding the k-th smallest element ) sort each 5-tuple TIME =  (n)

Finding the k-th smallest element ) find median of the middle n/5 elements TIME = ?

Finding the k-th smallest element ) find median of the middle n/5 elements TIME = T(n/5) We will use this element as the pivot

Finding the k-th smallest element At least ? Many elements in the array are  X

Finding the k-th smallest element At least ? Many elements in the array are  X

Finding the k-th smallest element At least 3n/10 elements in the array are  X

Finding the k-th smallest element At least 3n/10 elements in the array are  X

Finding the k-th smallest element At least 3n/10 elements in the array are  X XX XX

Finding the k-th smallest element At least 3n/10 elements in the array are  X XX XX Recurse, time ?

Finding the k-th smallest element At least 3n/10 elements in the array are  X XX XX Recurse, time  T(7n/10)

Finding the k-th smallest element XX XX recurse Split

Finding the k-th smallest element XX XX recurse  n) T(n/5)  n) T(7n/10)

Finding the k-th smallest element T(n)  T(n/5) + T(7n/10) + O(n)

Finding the k-th smallest element T(n)  T(n/5) + T(7n/10) + O(n) T(n)  d.n Induction step: T(n)  T(n/5) + T(7n/10) + O(n)  d.(n/5) + d.(7n/10) + O(n)  d.n + (O(n) – dn/10)  d.n

Why 5-tuples? XX XX recurse  n)

Why 5-tuples? XX XX recurse  n) T(2n/3) T(n/3)

Why 5-tuples? T(n)  T(n/3) + T(2n/3) +  (n)

Why 5-tuples? T(n)  T(n/3) + T(2n/3) +  (n) T(n)  c.n.ln n Induction step: T(n) = T(n/3) + T(2n/3) +  (n)  c.(n/3).ln (n/3) + c.(2n/3).ln (2n/3) +  (n)  c.n.ln n - c.n.((1/3)ln 3+(2/3)ln 3/2)+  (n)  c.n.ln n

Quicksort(A[b..c]) Quicksort(A[b..i]); Quicksort(A[j..c]); Split(A[b..c],x) xx xx xx i j b c

Quicksort(A[b..c]) Worst-case running time? How to make the worst-case running time O(n.log n) ?

Quicksort(A[b..c]) if pivot = median then the worst-case running time satisfies T(n) = 2T(n/2) + O(n)

Quicksort(A[b..c]) Quicksort(A[b..i]); Quicksort(A[j..c]); Split(A[b..c],x) xx xx xx i j b c x = random element of A[b..c]

Finding the k-th smallest element k =  n/2  = MEDIAN Split(A[1..n],x) xx xx j j  k  k-th smallest on left j<k  (k-j)-th smallest on right

Finding the k-th smallest element Select(k,A[c..d]) Split(A[c..d],x) xx xx j j  k  k-th smallest on left j<k  (k-j)-th smallest on right x=random element from A[c..d]

Finite probability space set  (sample space) function P:  R + (probability distribution)  P(x) = 1 x 

Finite probability space set  (sample space) function P:  R + (probability distribution) elements of  are called atomic events subsets of  are called events probability of an event A is  P(x) xAxA P(A)=  P(x) = 1 x 

Examples 1. Roll a (6 sided) dice. What is the probability that the number on the dice is even? 2. Flip two coins, what is the probability that they show the same symbol? 3. Flip five coins, what is the probability that they show the same symbol? 4. Mix a pack of 52 cards. What is the probability that all red cards come before all black cards?

Union bound P(A  B)  P(A) + P(B) P(A 1  A 2  …  A n )  P(A 1 ) + P(A 2 )+…+P(A n ) LEMMA: More generally:

Union bound P(A 1  A 2  …  A n )  P(A 1 ) + P(A 2 )+…+P(A n ) Suppose that the probability of winning in a lottery is What is the probability that somebody out of 100 people wins? A i = i-th person wins somebody wins = ?

Union bound P(A 1  A 2  …  A n )  P(A 1 ) + P(A 2 )+…+P(A n ) Suppose that the probability of winning in a lottery is What is the probability that somebody out of 100 people wins? A i = i-th person wins somebody wins = A 1  A 2  …  A 100

Union bound P(A 1  A 2  …  A n )  P(A 1 ) + P(A 2 )+…+P(A n ) Suppose that the probability of winning in a lottery is What is the probability that somebody out of 100 people wins? P(A 1  A 2  …  A 100 )  100*10 -6 = 10 -4

Union bound P(A 1  A 2  …  A n )  P(A 1 ) + P(A 2 )+…+P(A n ) Suppose that the probability of winning in a lottery is What is the probability that somebody out of 100 people wins? P(A 1  A 2  …  A 100 )  100*10 -6 = P(A 1  A 2  …  A 100 ) = 1–P(A C 1  A C 2  …  A C 100 ) = 1-P(A C 1 )P(A C 2 )…P(A C 100 ) = 1-( ) 100  0.99*10 -4

Independence Events A,B are independent if P(A  B) = P(A) * P(B)

Independence Events A,B are independent if P(A  B) = P(A) * P(B) “observing whether B happened gives no information on A” B A

Independence Events A,B are independent if P(A  B) = P(A) * P(B) “observing whether B happened gives no information on A” B A P(A|B) = P(A  B)/P(B) conditional probability of A, given B

Independence Events A,B are independent if P(A  B) = P(A) * P(B) P(A|B) = P(A)

Examples Roll two (6 sided) dice. Let S be their sum. 1) What is that probability that S=7 ? 2) What is the probability that S=7, conditioned on S being odd ? 3) Let A be the event that S is even and B the event that S is odd. Are A,B independent? 4) Let C be the event that S is divisible by 4. Are A,C independent? 5) Let D be the event that S is divisible by 3. Are A,D independent?

Examples A B C Are A,B independent ? Are A,C independent ? Are B,C independent ? Is it true that P(A  B  C)=P(A)P(B)P(C)?

Examples A B C Are A,B independent ? Are A,C independent ? Are B,C independent ? Is it true that P(A  B  C)=P(A)P(B)P(C)? Events A,B,C are pairwise independent but not (fully) independent

Full independence Events A 1,…,A n are (fully) independent If for every subset S  [n]:={1,2,…,n} P (  A i ) =  P(A i ) iSiS iSiS

Random variable set  (sample space) function P:  R + (probability distribution)  P(x) = 1 x  A random variable is a function Y :  R The expected value of Y is E[X] :=  P(x)* Y(x) x 

Examples Roll two dice. Let S be their sum. If S=7 then player A gives player B $6 otherwise player B gives player A $1 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12

Examples Roll two dice. Let S be their sum. If S=7 then player A gives player B $6 otherwise player B gives player A $1 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 -1, -1,-1,-1, -1, 6,-1,-1, -1, -1, -1 Expected income for B E[Y] = 6*(1/6)-1*(5/6)= 1/6 Y:

Linearity of expectation E[X  Y]  E[X] + E[Y] E[X 1  X 2  …  X n ]  E[X 1 ] + E[X 2 ]+…+E[X n ] LEMMA: More generally:

Linearity of expectation Everybody pays me $1 and writes their name on a card. I mix the cards and give everybody one card. If you get back the card with your name – I pay you $10. Let n be the number of people in the class. For what n is the game advantageous for me?

Linearity of expectation Everybody pays me $1 and writes their name on a card. I mix the cards and give everybody one card. If you get back the card with your name – I pay you $10. X 1 = -9 if player 1 gets his card back 1 otherwise E[X 1 ] = ?

Linearity of expectation Everybody pays me $1 and writes their name on a card. I mix the cards and give everybody one card. If you get back the card with your name – I pay you $10. X 1 = -9 if player 1 gets his card back 1 otherwise E[X 1 ] = -9/n + 1*(n-1)/n

Linearity of expectation Everybody pays me $1 and writes their name on a card. I mix the cards and give everybody one card. If you get back the card with your name – I pay you $10. X 1 = -9 if player 1 gets his card back 1 otherwise X 2 = -9 if player 2 gets his card back 1 otherwise E[X 1 +…+X n ] = E[X 1 ]+…+E[X n ] = n ( -9/n + 1*(n-1)/n ) = n – 10.

Expected number of coin-tosses until HEADS?

Expected number of coin-tosses until HEADS? 1/2 1 1/4 2 1/8 3 1/16 4 ….   n.2 -n = 2 n=1 

Expected number of dice-throws until you get “6” ?