SlideShare ist ein Scribd-Unternehmen logo
1 von 25
Randomized Algorithms
CS648

Lecture 2
• Randomized Algorithm for Approximate Median
• Elementary Probability theory
1
RANDOMIZED MONTE CARLO ALGORITHM
FOR
APPROXIMATE MEDIAN
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.

2
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
Can you give a short proof ?

5
½ - 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
n/4

Left Quarter

Elements of A arranged in
Increasing order of values

3n/4

Right Quarter

When does the algorithm err ?
To answer this question, try to characterize what
will be a bad sample S ?

7
Analyzing the error probability of
Rand-approx-median
n/4

Elements of A arranged in
Increasing order of values

Left Quarter

3n/4

Median of S

Right Quarter

Observation: Algorithm makes an error only if k/2 or more elements
sampled from the Right Quarter (or Left Quarter).

8
Analyzing the error probability of
Rand-approx-median
n/4

Elements of A arranged in
Increasing order of values

3n/4

Right Quarter

Left Quarter

¼

Exactly the same as the coin
tossing exercise we did !

9
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

A

Ω

14
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

A

B

Ω

17
Union of three Events

A

B

C

Ω

18
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”

B

Ω

22
Exercises

23
Independent Events

P(A ∩ B) = P(A) · P(B)

24
Exercises

25

Weitere ähnliche Inhalte

Was ist angesagt?

Continuous probability Business Statistics, Management
Continuous probability Business Statistics, ManagementContinuous probability Business Statistics, Management
Continuous probability Business Statistics, ManagementDebjit Das
 
Chapter 4 part2- Random Variables
Chapter 4 part2- Random VariablesChapter 4 part2- Random Variables
Chapter 4 part2- Random Variablesnszakir
 
Introduction to Probability
Introduction to ProbabilityIntroduction to Probability
Introduction to ProbabilityVikas Gupta
 
Discreet and continuous probability
Discreet and continuous probabilityDiscreet and continuous probability
Discreet and continuous probabilitynj1992
 
Probability concepts for Data Analytics
Probability concepts for Data AnalyticsProbability concepts for Data Analytics
Probability concepts for Data AnalyticsSSaudia
 
Continous random variable.
Continous random variable.Continous random variable.
Continous random variable.Shakeel Nouman
 
Sample Space and Event,Probability,The Axioms of Probability,Bayes Theorem
Sample Space and Event,Probability,The Axioms of Probability,Bayes TheoremSample Space and Event,Probability,The Axioms of Probability,Bayes Theorem
Sample Space and Event,Probability,The Axioms of Probability,Bayes TheoremBharath kumar Karanam
 
Heteroskedasticity
HeteroskedasticityHeteroskedasticity
Heteroskedasticityhalimuth
 
Chapter 1 random variables and probability distributions
Chapter 1   random variables and probability distributionsChapter 1   random variables and probability distributions
Chapter 1 random variables and probability distributionsAntonio F. Balatar Jr.
 
Probability 2(final)
Probability 2(final)Probability 2(final)
Probability 2(final)Khadiza Begum
 
Rational functions
Rational functionsRational functions
Rational functionstidtay81
 
02 Machine Learning - Introduction probability
02 Machine Learning - Introduction probability02 Machine Learning - Introduction probability
02 Machine Learning - Introduction probabilityAndres Mendez-Vazquez
 
binomial distribution
binomial distributionbinomial distribution
binomial distributionZarish Qaiser
 
Discrete probability distribution (complete)
Discrete probability distribution (complete)Discrete probability distribution (complete)
Discrete probability distribution (complete)ISYousafzai
 
Probability class 9 ____ CBSE
Probability class 9 ____ CBSEProbability class 9 ____ CBSE
Probability class 9 ____ CBSESmrithi Jaya
 
Binomial distribution
Binomial distributionBinomial distribution
Binomial distributionRobert Tinaro
 
Basic probability theory and statistics
Basic probability theory and statisticsBasic probability theory and statistics
Basic probability theory and statisticsLearnbay Datascience
 

Was ist angesagt? (20)

Continuous probability Business Statistics, Management
Continuous probability Business Statistics, ManagementContinuous probability Business Statistics, Management
Continuous probability Business Statistics, Management
 
Chapter 4 part2- Random Variables
Chapter 4 part2- Random VariablesChapter 4 part2- Random Variables
Chapter 4 part2- Random Variables
 
Re appr unit 15
Re   appr unit 15Re   appr unit 15
Re appr unit 15
 
Introduction to Probability
Introduction to ProbabilityIntroduction to Probability
Introduction to Probability
 
Discreet and continuous probability
Discreet and continuous probabilityDiscreet and continuous probability
Discreet and continuous probability
 
Probability concepts for Data Analytics
Probability concepts for Data AnalyticsProbability concepts for Data Analytics
Probability concepts for Data Analytics
 
Continous random variable.
Continous random variable.Continous random variable.
Continous random variable.
 
Sample Space and Event,Probability,The Axioms of Probability,Bayes Theorem
Sample Space and Event,Probability,The Axioms of Probability,Bayes TheoremSample Space and Event,Probability,The Axioms of Probability,Bayes Theorem
Sample Space and Event,Probability,The Axioms of Probability,Bayes Theorem
 
Heteroskedasticity
HeteroskedasticityHeteroskedasticity
Heteroskedasticity
 
Binomial probability distributions
Binomial probability distributions  Binomial probability distributions
Binomial probability distributions
 
Chapter 1 random variables and probability distributions
Chapter 1   random variables and probability distributionsChapter 1   random variables and probability distributions
Chapter 1 random variables and probability distributions
 
Probability 2(final)
Probability 2(final)Probability 2(final)
Probability 2(final)
 
Rational functions
Rational functionsRational functions
Rational functions
 
02 Machine Learning - Introduction probability
02 Machine Learning - Introduction probability02 Machine Learning - Introduction probability
02 Machine Learning - Introduction probability
 
binomial distribution
binomial distributionbinomial distribution
binomial distribution
 
Discrete probability distribution (complete)
Discrete probability distribution (complete)Discrete probability distribution (complete)
Discrete probability distribution (complete)
 
Probability class 9 ____ CBSE
Probability class 9 ____ CBSEProbability class 9 ____ CBSE
Probability class 9 ____ CBSE
 
Probability distributions
Probability distributions  Probability distributions
Probability distributions
 
Binomial distribution
Binomial distributionBinomial distribution
Binomial distribution
 
Basic probability theory and statistics
Basic probability theory and statisticsBasic probability theory and statistics
Basic probability theory and statistics
 

Andere mochten auch

Dignity presentation
Dignity presentationDignity presentation
Dignity presentationLili Coleman
 
Presentation%203
Presentation%203Presentation%203
Presentation%203Sanusia1
 
دعوة الشباب العصرية للإسلام
دعوة الشباب العصرية للإسلامدعوة الشباب العصرية للإسلام
دعوة الشباب العصرية للإسلامHassan Elagouz
 
إشراقات الإسراء ج1 للشيخ فوزي محمد أبوزيد
إشراقات الإسراء ج1 للشيخ فوزي محمد أبوزيدإشراقات الإسراء ج1 للشيخ فوزي محمد أبوزيد
إشراقات الإسراء ج1 للشيخ فوزي محمد أبوزيدHassan Elagouz
 
tabel comparativ lg contab
tabel comparativ lg contabtabel comparativ lg contab
tabel comparativ lg contabLaurentiu Marius
 
Lecture 3-cs648
Lecture 3-cs648Lecture 3-cs648
Lecture 3-cs648Rajiv Omar
 
كيف يحبك الله
كيف يحبك اللهكيف يحبك الله
كيف يحبك اللهHassan Elagouz
 
كتاب الكمالات المحمدية
كتاب الكمالات المحمديةكتاب الكمالات المحمدية
كتاب الكمالات المحمديةHassan Elagouz
 
ثانى اثنين لفضيلة الشيخ فوزى محمد أبوزيد
 ثانى اثنين لفضيلة الشيخ فوزى محمد أبوزيد  ثانى اثنين لفضيلة الشيخ فوزى محمد أبوزيد
ثانى اثنين لفضيلة الشيخ فوزى محمد أبوزيد Hassan Elagouz
 
Material informativ scaderea cotei de tva
Material informativ  scaderea cotei de tvaMaterial informativ  scaderea cotei de tva
Material informativ scaderea cotei de tvaLaurentiu Marius
 
North American Precambrian Craton Part A
North American Precambrian Craton Part ANorth American Precambrian Craton Part A
North American Precambrian Craton Part AWilliam Szary
 
Q1 evaluation (Pooja)
Q1 evaluation (Pooja)Q1 evaluation (Pooja)
Q1 evaluation (Pooja)GroupFiveMV
 

Andere mochten auch (20)

Dignity presentation
Dignity presentationDignity presentation
Dignity presentation
 
Shabang
ShabangShabang
Shabang
 
Tabel accize
Tabel accizeTabel accize
Tabel accize
 
Presentation%203
Presentation%203Presentation%203
Presentation%203
 
دعوة الشباب العصرية للإسلام
دعوة الشباب العصرية للإسلامدعوة الشباب العصرية للإسلام
دعوة الشباب العصرية للإسلام
 
Strategic Networking for Oil & Gas Professionals
Strategic Networking for Oil & Gas ProfessionalsStrategic Networking for Oil & Gas Professionals
Strategic Networking for Oil & Gas Professionals
 
إشراقات الإسراء ج1 للشيخ فوزي محمد أبوزيد
إشراقات الإسراء ج1 للشيخ فوزي محمد أبوزيدإشراقات الإسراء ج1 للشيخ فوزي محمد أبوزيد
إشراقات الإسراء ج1 للشيخ فوزي محمد أبوزيد
 
Q4 - Jemima Chamberlin
Q4 - Jemima ChamberlinQ4 - Jemima Chamberlin
Q4 - Jemima Chamberlin
 
Tabel - modif. CPP
Tabel - modif. CPPTabel - modif. CPP
Tabel - modif. CPP
 
tabel comparativ lg contab
tabel comparativ lg contabtabel comparativ lg contab
tabel comparativ lg contab
 
Lecture 3-cs648
Lecture 3-cs648Lecture 3-cs648
Lecture 3-cs648
 
Accize
AccizeAccize
Accize
 
Ghid ANAF
Ghid ANAFGhid ANAF
Ghid ANAF
 
كيف يحبك الله
كيف يحبك اللهكيف يحبك الله
كيف يحبك الله
 
كتاب الكمالات المحمدية
كتاب الكمالات المحمديةكتاب الكمالات المحمدية
كتاب الكمالات المحمدية
 
Panic Cord
Panic CordPanic Cord
Panic Cord
 
ثانى اثنين لفضيلة الشيخ فوزى محمد أبوزيد
 ثانى اثنين لفضيلة الشيخ فوزى محمد أبوزيد  ثانى اثنين لفضيلة الشيخ فوزى محمد أبوزيد
ثانى اثنين لفضيلة الشيخ فوزى محمد أبوزيد
 
Material informativ scaderea cotei de tva
Material informativ  scaderea cotei de tvaMaterial informativ  scaderea cotei de tva
Material informativ scaderea cotei de tva
 
North American Precambrian Craton Part A
North American Precambrian Craton Part ANorth American Precambrian Craton Part A
North American Precambrian Craton Part A
 
Q1 evaluation (Pooja)
Q1 evaluation (Pooja)Q1 evaluation (Pooja)
Q1 evaluation (Pooja)
 

Ähnlich wie Lecture 2-cs648

Topic 1 __basic_probability_concepts
Topic 1 __basic_probability_conceptsTopic 1 __basic_probability_concepts
Topic 1 __basic_probability_conceptsMaleakhi Agung Wijaya
 
powerpoints probability.pptx
powerpoints probability.pptxpowerpoints probability.pptx
powerpoints probability.pptxcarrie mixto
 
Probability theory discrete probability distribution
Probability theory discrete probability distributionProbability theory discrete probability distribution
Probability theory discrete probability distributionsamarthpawar9890
 
chapter five.pptx
chapter five.pptxchapter five.pptx
chapter five.pptxAbebeNega
 
Advanced Econometrics L5-6.pptx
Advanced Econometrics L5-6.pptxAdvanced Econometrics L5-6.pptx
Advanced Econometrics L5-6.pptxakashayosha
 
1 - Probabilty Introduction .ppt
1 - Probabilty Introduction .ppt1 - Probabilty Introduction .ppt
1 - Probabilty Introduction .pptVivek Bhartiya
 
PRML Chapter 1
PRML Chapter 1PRML Chapter 1
PRML Chapter 1Sunwoo Kim
 
Discrete Probability Distributions
Discrete Probability DistributionsDiscrete Probability Distributions
Discrete Probability Distributionsmandalina landy
 
Iteration method-Solution of algebraic and Transcendental Equations.
Iteration method-Solution of algebraic and Transcendental Equations.Iteration method-Solution of algebraic and Transcendental Equations.
Iteration method-Solution of algebraic and Transcendental Equations.AmitKumar8151
 
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
 
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
 
Chapter Five.ppthhjhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
Chapter Five.ppthhjhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhChapter Five.ppthhjhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
Chapter Five.ppthhjhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhbeshahashenafe20
 

Ähnlich wie Lecture 2-cs648 (20)

Probability
ProbabilityProbability
Probability
 
Stat.pptx
Stat.pptxStat.pptx
Stat.pptx
 
Topic 1 __basic_probability_concepts
Topic 1 __basic_probability_conceptsTopic 1 __basic_probability_concepts
Topic 1 __basic_probability_concepts
 
powerpoints probability.pptx
powerpoints probability.pptxpowerpoints probability.pptx
powerpoints probability.pptx
 
Probability theory discrete probability distribution
Probability theory discrete probability distributionProbability theory discrete probability distribution
Probability theory discrete probability distribution
 
chapter five.pptx
chapter five.pptxchapter five.pptx
chapter five.pptx
 
Advanced Econometrics L5-6.pptx
Advanced Econometrics L5-6.pptxAdvanced Econometrics L5-6.pptx
Advanced Econometrics L5-6.pptx
 
Probability
ProbabilityProbability
Probability
 
1 - Probabilty Introduction .ppt
1 - Probabilty Introduction .ppt1 - Probabilty Introduction .ppt
1 - Probabilty Introduction .ppt
 
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
 
PRML Chapter 1
PRML Chapter 1PRML Chapter 1
PRML Chapter 1
 
Discrete Probability Distributions
Discrete Probability DistributionsDiscrete Probability Distributions
Discrete Probability Distributions
 
Probability Distribution
Probability DistributionProbability Distribution
Probability Distribution
 
Iteration method-Solution of algebraic and Transcendental Equations.
Iteration method-Solution of algebraic and Transcendental Equations.Iteration method-Solution of algebraic and Transcendental Equations.
Iteration method-Solution of algebraic and Transcendental Equations.
 
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
 
03 notes
03 notes03 notes
03 notes
 
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
 
Math quarter 2 module 8
Math quarter 2   module 8Math quarter 2   module 8
Math quarter 2 module 8
 
Chapter Five.ppthhjhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
Chapter Five.ppthhjhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhChapter Five.ppthhjhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
Chapter Five.ppthhjhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
 

Mehr von Rajiv Omar

Lecture 6-cs345-2014
Lecture 6-cs345-2014Lecture 6-cs345-2014
Lecture 6-cs345-2014Rajiv Omar
 
Lecture 7-cs345-2014
Lecture 7-cs345-2014Lecture 7-cs345-2014
Lecture 7-cs345-2014Rajiv Omar
 
Lecture 14-2013
Lecture 14-2013Lecture 14-2013
Lecture 14-2013Rajiv Omar
 
Lecture 13-cs648
Lecture 13-cs648Lecture 13-cs648
Lecture 13-cs648Rajiv Omar
 
Lecture 14-cs648-2013
Lecture 14-cs648-2013Lecture 14-cs648-2013
Lecture 14-cs648-2013Rajiv Omar
 
Lecture 17-cs648
Lecture 17-cs648Lecture 17-cs648
Lecture 17-cs648Rajiv Omar
 
Lecture 18-cs648
Lecture 18-cs648Lecture 18-cs648
Lecture 18-cs648Rajiv Omar
 
Lecture 19-cs648
Lecture 19-cs648Lecture 19-cs648
Lecture 19-cs648Rajiv Omar
 
Lecture 20-cs648
Lecture 20-cs648Lecture 20-cs648
Lecture 20-cs648Rajiv Omar
 
Lecture 22-cs648
Lecture 22-cs648Lecture 22-cs648
Lecture 22-cs648Rajiv Omar
 
Lecture 4-cs648
Lecture 4-cs648Lecture 4-cs648
Lecture 4-cs648Rajiv Omar
 
Lecture 5-cs648
Lecture 5-cs648Lecture 5-cs648
Lecture 5-cs648Rajiv Omar
 
Lecture 6-cs648
Lecture 6-cs648Lecture 6-cs648
Lecture 6-cs648Rajiv Omar
 
Lecture 7-cs648
Lecture 7-cs648Lecture 7-cs648
Lecture 7-cs648Rajiv Omar
 
Lecture 8-cs648-2013
Lecture 8-cs648-2013Lecture 8-cs648-2013
Lecture 8-cs648-2013Rajiv Omar
 
Lecture 9-cs648-2013
Lecture 9-cs648-2013Lecture 9-cs648-2013
Lecture 9-cs648-2013Rajiv Omar
 
Lecture 1-cs648
Lecture 1-cs648Lecture 1-cs648
Lecture 1-cs648Rajiv Omar
 
Lecture 10-cs648=2013
Lecture 10-cs648=2013Lecture 10-cs648=2013
Lecture 10-cs648=2013Rajiv Omar
 

Mehr von Rajiv Omar (20)

Lecture 6-cs345-2014
Lecture 6-cs345-2014Lecture 6-cs345-2014
Lecture 6-cs345-2014
 
Lecture 7-cs345-2014
Lecture 7-cs345-2014Lecture 7-cs345-2014
Lecture 7-cs345-2014
 
Lecture 14-2013
Lecture 14-2013Lecture 14-2013
Lecture 14-2013
 
Lecture 15
Lecture 15Lecture 15
Lecture 15
 
Lecture 16
Lecture 16Lecture 16
Lecture 16
 
Lecture 13-cs648
Lecture 13-cs648Lecture 13-cs648
Lecture 13-cs648
 
Lecture 14-cs648-2013
Lecture 14-cs648-2013Lecture 14-cs648-2013
Lecture 14-cs648-2013
 
Lecture 17-cs648
Lecture 17-cs648Lecture 17-cs648
Lecture 17-cs648
 
Lecture 18-cs648
Lecture 18-cs648Lecture 18-cs648
Lecture 18-cs648
 
Lecture 19-cs648
Lecture 19-cs648Lecture 19-cs648
Lecture 19-cs648
 
Lecture 20-cs648
Lecture 20-cs648Lecture 20-cs648
Lecture 20-cs648
 
Lecture 22-cs648
Lecture 22-cs648Lecture 22-cs648
Lecture 22-cs648
 
Lecture 4-cs648
Lecture 4-cs648Lecture 4-cs648
Lecture 4-cs648
 
Lecture 5-cs648
Lecture 5-cs648Lecture 5-cs648
Lecture 5-cs648
 
Lecture 6-cs648
Lecture 6-cs648Lecture 6-cs648
Lecture 6-cs648
 
Lecture 7-cs648
Lecture 7-cs648Lecture 7-cs648
Lecture 7-cs648
 
Lecture 8-cs648-2013
Lecture 8-cs648-2013Lecture 8-cs648-2013
Lecture 8-cs648-2013
 
Lecture 9-cs648-2013
Lecture 9-cs648-2013Lecture 9-cs648-2013
Lecture 9-cs648-2013
 
Lecture 1-cs648
Lecture 1-cs648Lecture 1-cs648
Lecture 1-cs648
 
Lecture 10-cs648=2013
Lecture 10-cs648=2013Lecture 10-cs648=2013
Lecture 10-cs648=2013
 

Kürzlich hochgeladen

Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 

Kürzlich hochgeladen (20)

Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 

Lecture 2-cs648

  • 1. Randomized Algorithms CS648 Lecture 2 • Randomized Algorithm for Approximate Median • Elementary Probability theory 1
  • 2. RANDOMIZED MONTE CARLO ALGORITHM FOR APPROXIMATE MEDIAN 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. 2
  • 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 Can you give a short proof ? 5
  • 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 n/4 Left Quarter Elements of A arranged in Increasing order of values 3n/4 Right Quarter When does the algorithm err ? To answer this question, try to characterize what will be a bad sample S ? 7
  • 8. Analyzing the error probability of Rand-approx-median n/4 Elements of A arranged in Increasing order of values Left Quarter 3n/4 Median of S Right Quarter Observation: Algorithm makes an error only if k/2 or more elements sampled from the Right Quarter (or Left Quarter). 8
  • 9. Analyzing the error probability of Rand-approx-median n/4 Elements of A arranged in Increasing order of values 3n/4 Right Quarter Left Quarter ¼ Exactly the same as the coin tossing exercise we did ! 9
  • 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 A Ω 14
  • 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 A B Ω 17
  • 18. Union of three Events A B C Ω 18
  • 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” B Ω 22
  • 24. Independent Events P(A ∩ B) = P(A) · P(B) 24