SlideShare a Scribd company logo
1 of 25
Randomized Algorithms
CS648
Lecture 2
• Randomized Algorithm for Approximate Median
• Elementary Probability theory
1
RANDOMIZED MONTE CARLO ALGORITHM
FOR
APPROXIMATE MEDIAN
2
This lecture was delivered at slow pace and its flavor was that of a
tutorial.
Reason: To show that designing and analyzing a randomized
algorithm demands right insight and just elementary probability.
A simple probability exercise
3
4
Approximate median
Definition: Given an array A[] storing n numbers and ϵ > 0, compute an
element whose rank is in the range [(1- ϵ)n/2, (1+ ϵ)n/2].
Best Deterministic Algorithm:
• “Median of Medians” algorithm for finding exact median
• Running time: O(n)
• No faster algorithm possible for approximate median
5
Can you give a short proof ?
½ - Approximate median
A Randomized Algorithm
Rand-Approx-Median(A)
1. Let k  c log n;
2. S  ∅;
3. For i=1 to k
4. x  an element selected randomly uniformly from A;
5. S  S U {x};
6. Sort S.
7. Report the median of S.
Running time: O(log n loglog n)
6
Analyzing the error probability of
Rand-approx-median
7
Elements of A arranged in
Increasing order of values
n/4 3n/4
Right QuarterLeft Quarter
When does the algorithm err ?
To answer this question, try to characterize what
will be a bad sample S ?
Analyzing the error probability of
Rand-approx-median
Observation: Algorithm makes an error only if k/2 or more elements
sampled from the Right Quarter (or Left Quarter).
8
n/4
Left Quarter Right Quarter
Elements of A arranged in
Increasing order of values
3n/4 Median of S
Analyzing the error probability of
Rand-approx-median
9
Elements of A arranged in
Increasing order of values
n/4 3n/4
Right QuarterLeft Quarter
Exactly the same as the coin
tossing exercise we did !
¼
Main result we discussed
10
ELEMENTARY PROBABILITY THEORY
(IT IS SO SIMPLE THAT YOU UNDERESTIMATE ITS ELEGANCE AND POWER)
11
Elementary probability theory
(Relevant for CS648)
• We shall mainly deal with discrete probability theory in this course.
• We shall take the set theoretic approach to explain probability theory.
Consider any random experiment :
o Tossing a coin 5 times.
o Throwing a dice 2 times.
o Selecting a number randomly uniformly from [1..n].
How to capture the following facts in the theory of probability ?
1. Outcome will always be from a specified set.
2. Likelihood of each possible outcome is non-negative.
3. We may be interested in a collection of outcomes.
12
Probability Space
13
Ω
Event in a Probability Space
14
A
Ω
Exercises
A randomized algorithm can also be viewed as a random experiment.
1. What is the sample space associated with Randomized Quick sort ?
2. What is the sample space associated with Rand-approx-median
algorithm ?
15
An Important Advice
In the following slides, we shall state well known equations
(highlighted in yellow boxes) from probability theory.
• You should internalize them fully.
• We shall use them crucially in this course.
• Make sincere attempts to solve exercises that follow.
16
Union of two Events
17
A
B Ω
Union of three Events
18
A B
C Ω
Exercises
19
Conditional Probability
20
Exercises
• A man possesses five coins, two of which are double-headed, one is
double-tailed, and two are normal. He shuts his eyes, picks a coin at
random, and tosses it. What is the probability that the lower face of the
coin is a head ? He opens his eyes and sees that the coin is showing heads;
what it the probability that the lower face is a head ? He shuts his eyes
again, and tosses the coin again. What is the probability that the lower
face is a head ? He opens his eyes and sees that the coin is showing heads;
what is the probability that the lower face is a head ? He discards this coin,
picks another at random, and tosses it. What is the probability that it
shows heads ?
21
Partition of sample space and
an “important Equation”
22
Ω
B
Exercises
23
Independent Events
24
P(A ∩ B) = P(A) · P(B)
Exercises
25

More Related Content

What's hot

Chapter 4 part2- Random Variables
Chapter 4 part2- Random VariablesChapter 4 part2- Random Variables
Chapter 4 part2- Random Variablesnszakir
 
Applied numerical methods lec3
Applied numerical methods lec3Applied numerical methods lec3
Applied numerical methods lec3Yasser Ahmed
 
Chapter 2 discrete_random_variable_2009
Chapter 2 discrete_random_variable_2009Chapter 2 discrete_random_variable_2009
Chapter 2 discrete_random_variable_2009ayimsevenfold
 
random variables-descriptive and contincuous
random variables-descriptive and contincuousrandom variables-descriptive and contincuous
random variables-descriptive and contincuousar9530
 
random variable and distribution
random variable and distributionrandom variable and distribution
random variable and distributionlovemucheca
 
Chapter4
Chapter4Chapter4
Chapter4Vu Vo
 
Probability, Discrete Probability, Normal Probabilty
Probability, Discrete Probability, Normal ProbabiltyProbability, Discrete Probability, Normal Probabilty
Probability, Discrete Probability, Normal ProbabiltyFaisal Hussain
 
Discrete Probability Distributions
Discrete Probability DistributionsDiscrete Probability Distributions
Discrete Probability Distributionsmandalina landy
 
Continous random variable.
Continous random variable.Continous random variable.
Continous random variable.Shakeel Nouman
 
Introduction to random variables
Introduction to random variablesIntroduction to random variables
Introduction to random variablesHadley Wickham
 
Limits of a Function
Limits of a FunctionLimits of a Function
Limits of a FunctionJesusDel2
 

What's hot (20)

Chapter 4 part2- Random Variables
Chapter 4 part2- Random VariablesChapter 4 part2- Random Variables
Chapter 4 part2- Random Variables
 
Applied numerical methods lec3
Applied numerical methods lec3Applied numerical methods lec3
Applied numerical methods lec3
 
Chapter 2 discrete_random_variable_2009
Chapter 2 discrete_random_variable_2009Chapter 2 discrete_random_variable_2009
Chapter 2 discrete_random_variable_2009
 
random variables-descriptive and contincuous
random variables-descriptive and contincuousrandom variables-descriptive and contincuous
random variables-descriptive and contincuous
 
numerical methods
numerical methodsnumerical methods
numerical methods
 
Business statistics homework help
Business statistics homework helpBusiness statistics homework help
Business statistics homework help
 
5 random variables
5 random variables5 random variables
5 random variables
 
Regression
Regression  Regression
Regression
 
Discrete and Continuous Random Variables
Discrete and Continuous Random VariablesDiscrete and Continuous Random Variables
Discrete and Continuous Random Variables
 
random variable and distribution
random variable and distributionrandom variable and distribution
random variable and distribution
 
Chapter4
Chapter4Chapter4
Chapter4
 
8 random variable
8 random variable8 random variable
8 random variable
 
U unit7 ssb
U unit7 ssbU unit7 ssb
U unit7 ssb
 
Stochastic Processes Homework Help
Stochastic Processes Homework Help Stochastic Processes Homework Help
Stochastic Processes Homework Help
 
Probability, Discrete Probability, Normal Probabilty
Probability, Discrete Probability, Normal ProbabiltyProbability, Discrete Probability, Normal Probabilty
Probability, Discrete Probability, Normal Probabilty
 
Discrete Probability Distributions
Discrete Probability DistributionsDiscrete Probability Distributions
Discrete Probability Distributions
 
Continous random variable.
Continous random variable.Continous random variable.
Continous random variable.
 
Introduction to random variables
Introduction to random variablesIntroduction to random variables
Introduction to random variables
 
Statistics Homework Help
Statistics Homework HelpStatistics Homework Help
Statistics Homework Help
 
Limits of a Function
Limits of a FunctionLimits of a Function
Limits of a Function
 

Similar to Lecture 2-cs648 Randomized Algorithms

Lecture 2-cs648
Lecture 2-cs648Lecture 2-cs648
Lecture 2-cs648Rajiv Omar
 
powerpoints probability.pptx
powerpoints probability.pptxpowerpoints probability.pptx
powerpoints probability.pptxcarrie mixto
 
1 - Probabilty Introduction .ppt
1 - Probabilty Introduction .ppt1 - Probabilty Introduction .ppt
1 - Probabilty Introduction .pptVivek Bhartiya
 
chapter five.pptx
chapter five.pptxchapter five.pptx
chapter five.pptxAbebeNega
 
Probability theory discrete probability distribution
Probability theory discrete probability distributionProbability theory discrete probability distribution
Probability theory discrete probability distributionsamarthpawar9890
 
Chapter Five.ppthhjhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
Chapter Five.ppthhjhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhChapter Five.ppthhjhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
Chapter Five.ppthhjhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhbeshahashenafe20
 
Chapter Five.ppthhjhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
Chapter Five.ppthhjhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhChapter Five.ppthhjhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
Chapter Five.ppthhjhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhbeshahashenafe20
 
Topic 1 __basic_probability_concepts
Topic 1 __basic_probability_conceptsTopic 1 __basic_probability_concepts
Topic 1 __basic_probability_conceptsMaleakhi Agung Wijaya
 
Binomial distribution good
Binomial distribution goodBinomial distribution good
Binomial distribution goodZahida Pervaiz
 
1.3.2 Inductive and Deductive Reasoning
1.3.2 Inductive and Deductive Reasoning1.3.2 Inductive and Deductive Reasoning
1.3.2 Inductive and Deductive Reasoningsmiller5
 
PRML Chapter 1
PRML Chapter 1PRML Chapter 1
PRML Chapter 1Sunwoo Kim
 
C2 st lecture 13 revision for test b handout
C2 st lecture 13   revision for test b handoutC2 st lecture 13   revision for test b handout
C2 st lecture 13 revision for test b handoutfatima d
 

Similar to Lecture 2-cs648 Randomized Algorithms (20)

Lecture 2-cs648
Lecture 2-cs648Lecture 2-cs648
Lecture 2-cs648
 
Probability Theory for Data Scientists
Probability Theory for Data ScientistsProbability Theory for Data Scientists
Probability Theory for Data Scientists
 
powerpoints probability.pptx
powerpoints probability.pptxpowerpoints probability.pptx
powerpoints probability.pptx
 
Probability
ProbabilityProbability
Probability
 
Stat.pptx
Stat.pptxStat.pptx
Stat.pptx
 
1 - Probabilty Introduction .ppt
1 - Probabilty Introduction .ppt1 - Probabilty Introduction .ppt
1 - Probabilty Introduction .ppt
 
chapter five.pptx
chapter five.pptxchapter five.pptx
chapter five.pptx
 
Binomial probability distributions
Binomial probability distributions  Binomial probability distributions
Binomial probability distributions
 
Chapter7ppt.pdf
Chapter7ppt.pdfChapter7ppt.pdf
Chapter7ppt.pdf
 
Probability and Statistics - Week 1
Probability and Statistics - Week 1Probability and Statistics - Week 1
Probability and Statistics - Week 1
 
Probability theory discrete probability distribution
Probability theory discrete probability distributionProbability theory discrete probability distribution
Probability theory discrete probability distribution
 
Chapter Five.ppthhjhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
Chapter Five.ppthhjhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhChapter Five.ppthhjhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
Chapter Five.ppthhjhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
 
Chapter Five.ppthhjhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
Chapter Five.ppthhjhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhChapter Five.ppthhjhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
Chapter Five.ppthhjhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
 
Topic 1 __basic_probability_concepts
Topic 1 __basic_probability_conceptsTopic 1 __basic_probability_concepts
Topic 1 __basic_probability_concepts
 
Probability
ProbabilityProbability
Probability
 
2주차
2주차2주차
2주차
 
Binomial distribution good
Binomial distribution goodBinomial distribution good
Binomial distribution good
 
1.3.2 Inductive and Deductive Reasoning
1.3.2 Inductive and Deductive Reasoning1.3.2 Inductive and Deductive Reasoning
1.3.2 Inductive and Deductive Reasoning
 
PRML Chapter 1
PRML Chapter 1PRML Chapter 1
PRML Chapter 1
 
C2 st lecture 13 revision for test b handout
C2 st lecture 13   revision for test b handoutC2 st lecture 13   revision for test b handout
C2 st lecture 13 revision for test b handout
 

More from Anshul Yadav

Lecture 14-cs648-2013
Lecture 14-cs648-2013Lecture 14-cs648-2013
Lecture 14-cs648-2013Anshul Yadav
 
Theoretical assign-2-hints
Theoretical assign-2-hintsTheoretical assign-2-hints
Theoretical assign-2-hintsAnshul Yadav
 
Lecture 12-cs648-2013 Randomized Algorithms
Lecture 12-cs648-2013 Randomized AlgorithmsLecture 12-cs648-2013 Randomized Algorithms
Lecture 12-cs648-2013 Randomized AlgorithmsAnshul Yadav
 
Lecture 11-cs648-2013 Randomized Algorithms
Lecture 11-cs648-2013 Randomized AlgorithmsLecture 11-cs648-2013 Randomized Algorithms
Lecture 11-cs648-2013 Randomized AlgorithmsAnshul Yadav
 
Lecture 10-cs648=2013 Randomized Algorithms
Lecture 10-cs648=2013 Randomized AlgorithmsLecture 10-cs648=2013 Randomized Algorithms
Lecture 10-cs648=2013 Randomized AlgorithmsAnshul Yadav
 
Lecture 9-cs648-2013 Randomized Algorithms
Lecture 9-cs648-2013 Randomized AlgorithmsLecture 9-cs648-2013 Randomized Algorithms
Lecture 9-cs648-2013 Randomized AlgorithmsAnshul Yadav
 
Lecture 6-cs648 Randomized Algorithms
Lecture 6-cs648 Randomized AlgorithmsLecture 6-cs648 Randomized Algorithms
Lecture 6-cs648 Randomized AlgorithmsAnshul Yadav
 
Lecture 5-cs648 Randomized Algorithms
Lecture 5-cs648 Randomized AlgorithmsLecture 5-cs648 Randomized Algorithms
Lecture 5-cs648 Randomized AlgorithmsAnshul Yadav
 
Lecture 4-cs648 Randomized Algorithms
Lecture 4-cs648 Randomized AlgorithmsLecture 4-cs648 Randomized Algorithms
Lecture 4-cs648 Randomized AlgorithmsAnshul Yadav
 
Lecture 3-cs648 Randomized Algorithms
Lecture 3-cs648 Randomized AlgorithmsLecture 3-cs648 Randomized Algorithms
Lecture 3-cs648 Randomized AlgorithmsAnshul Yadav
 
Lecture 7-cs648 Randomized Algorithms
Lecture 7-cs648 Randomized AlgorithmsLecture 7-cs648 Randomized Algorithms
Lecture 7-cs648 Randomized AlgorithmsAnshul Yadav
 

More from Anshul Yadav (17)

Lecture 19-cs648
Lecture 19-cs648Lecture 19-cs648
Lecture 19-cs648
 
Lecture 17-cs648
Lecture 17-cs648Lecture 17-cs648
Lecture 17-cs648
 
Lecture 14-cs648-2013
Lecture 14-cs648-2013Lecture 14-cs648-2013
Lecture 14-cs648-2013
 
Lecture 13-cs648
Lecture 13-cs648Lecture 13-cs648
Lecture 13-cs648
 
Lecture 18-cs648
Lecture 18-cs648Lecture 18-cs648
Lecture 18-cs648
 
Lecture 16
Lecture 16Lecture 16
Lecture 16
 
Theoretical assign-2-hints
Theoretical assign-2-hintsTheoretical assign-2-hints
Theoretical assign-2-hints
 
Lecture 12-cs648-2013 Randomized Algorithms
Lecture 12-cs648-2013 Randomized AlgorithmsLecture 12-cs648-2013 Randomized Algorithms
Lecture 12-cs648-2013 Randomized Algorithms
 
Lecture 11-cs648-2013 Randomized Algorithms
Lecture 11-cs648-2013 Randomized AlgorithmsLecture 11-cs648-2013 Randomized Algorithms
Lecture 11-cs648-2013 Randomized Algorithms
 
Lecture 10-cs648=2013 Randomized Algorithms
Lecture 10-cs648=2013 Randomized AlgorithmsLecture 10-cs648=2013 Randomized Algorithms
Lecture 10-cs648=2013 Randomized Algorithms
 
Lecture 9-cs648-2013 Randomized Algorithms
Lecture 9-cs648-2013 Randomized AlgorithmsLecture 9-cs648-2013 Randomized Algorithms
Lecture 9-cs648-2013 Randomized Algorithms
 
Lecture 6-cs648 Randomized Algorithms
Lecture 6-cs648 Randomized AlgorithmsLecture 6-cs648 Randomized Algorithms
Lecture 6-cs648 Randomized Algorithms
 
Lecture 5-cs648 Randomized Algorithms
Lecture 5-cs648 Randomized AlgorithmsLecture 5-cs648 Randomized Algorithms
Lecture 5-cs648 Randomized Algorithms
 
Lecture 4-cs648 Randomized Algorithms
Lecture 4-cs648 Randomized AlgorithmsLecture 4-cs648 Randomized Algorithms
Lecture 4-cs648 Randomized Algorithms
 
Lecture 3-cs648 Randomized Algorithms
Lecture 3-cs648 Randomized AlgorithmsLecture 3-cs648 Randomized Algorithms
Lecture 3-cs648 Randomized Algorithms
 
Lecture 7-cs648 Randomized Algorithms
Lecture 7-cs648 Randomized AlgorithmsLecture 7-cs648 Randomized Algorithms
Lecture 7-cs648 Randomized Algorithms
 
Lecture 1-cs648
Lecture 1-cs648Lecture 1-cs648
Lecture 1-cs648
 

Recently uploaded

CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Hyundai Motor Group
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 

Recently uploaded (20)

CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 

Lecture 2-cs648 Randomized Algorithms

  • 1. Randomized Algorithms CS648 Lecture 2 • Randomized Algorithm for Approximate Median • Elementary Probability theory 1
  • 2. RANDOMIZED MONTE CARLO ALGORITHM FOR APPROXIMATE MEDIAN 2 This lecture was delivered at slow pace and its flavor was that of a tutorial. Reason: To show that designing and analyzing a randomized algorithm demands right insight and just elementary probability.
  • 3. A simple probability exercise 3
  • 4. 4
  • 5. Approximate median Definition: Given an array A[] storing n numbers and ϵ > 0, compute an element whose rank is in the range [(1- ϵ)n/2, (1+ ϵ)n/2]. Best Deterministic Algorithm: • “Median of Medians” algorithm for finding exact median • Running time: O(n) • No faster algorithm possible for approximate median 5 Can you give a short proof ?
  • 6. ½ - Approximate median A Randomized Algorithm Rand-Approx-Median(A) 1. Let k  c log n; 2. S  ∅; 3. For i=1 to k 4. x  an element selected randomly uniformly from A; 5. S  S U {x}; 6. Sort S. 7. Report the median of S. Running time: O(log n loglog n) 6
  • 7. Analyzing the error probability of Rand-approx-median 7 Elements of A arranged in Increasing order of values n/4 3n/4 Right QuarterLeft Quarter When does the algorithm err ? To answer this question, try to characterize what will be a bad sample S ?
  • 8. Analyzing the error probability of Rand-approx-median Observation: Algorithm makes an error only if k/2 or more elements sampled from the Right Quarter (or Left Quarter). 8 n/4 Left Quarter Right Quarter Elements of A arranged in Increasing order of values 3n/4 Median of S
  • 9. Analyzing the error probability of Rand-approx-median 9 Elements of A arranged in Increasing order of values n/4 3n/4 Right QuarterLeft Quarter Exactly the same as the coin tossing exercise we did ! ¼
  • 10. Main result we discussed 10
  • 11. ELEMENTARY PROBABILITY THEORY (IT IS SO SIMPLE THAT YOU UNDERESTIMATE ITS ELEGANCE AND POWER) 11
  • 12. Elementary probability theory (Relevant for CS648) • We shall mainly deal with discrete probability theory in this course. • We shall take the set theoretic approach to explain probability theory. Consider any random experiment : o Tossing a coin 5 times. o Throwing a dice 2 times. o Selecting a number randomly uniformly from [1..n]. How to capture the following facts in the theory of probability ? 1. Outcome will always be from a specified set. 2. Likelihood of each possible outcome is non-negative. 3. We may be interested in a collection of outcomes. 12
  • 14. Event in a Probability Space 14 A Ω
  • 15. Exercises A randomized algorithm can also be viewed as a random experiment. 1. What is the sample space associated with Randomized Quick sort ? 2. What is the sample space associated with Rand-approx-median algorithm ? 15
  • 16. An Important Advice In the following slides, we shall state well known equations (highlighted in yellow boxes) from probability theory. • You should internalize them fully. • We shall use them crucially in this course. • Make sincere attempts to solve exercises that follow. 16
  • 17. Union of two Events 17 A B Ω
  • 18. Union of three Events 18 A B C Ω
  • 21. Exercises • A man possesses five coins, two of which are double-headed, one is double-tailed, and two are normal. He shuts his eyes, picks a coin at random, and tosses it. What is the probability that the lower face of the coin is a head ? He opens his eyes and sees that the coin is showing heads; what it the probability that the lower face is a head ? He shuts his eyes again, and tosses the coin again. What is the probability that the lower face is a head ? He opens his eyes and sees that the coin is showing heads; what is the probability that the lower face is a head ? He discards this coin, picks another at random, and tosses it. What is the probability that it shows heads ? 21
  • 22. Partition of sample space and an “important Equation” 22 Ω B
  • 24. Independent Events 24 P(A ∩ B) = P(A) · P(B)