probability in programmingprakash/talks/tsd.pdf · 2015-05-14 · why does one use probability? •...
TRANSCRIPT
![Page 1: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/1.jpg)
Probability in Programming
Prakash Panangaden School of Computer Science
McGill University
![Page 2: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/2.jpg)
Two crucial issues
![Page 3: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/3.jpg)
Two crucial issues
• Correctness of software:
![Page 4: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/4.jpg)
Two crucial issues
• Correctness of software:
• with respect to precise specifications.
![Page 5: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/5.jpg)
Two crucial issues
• Correctness of software:
• with respect to precise specifications.
• Efficiency of code:
![Page 6: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/6.jpg)
Two crucial issues
• Correctness of software:
• with respect to precise specifications.
• Efficiency of code:
• based on well-designed algorithms.
![Page 7: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/7.jpg)
Logic is the key
![Page 8: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/8.jpg)
Logic is the key• Precise specifications have to be made in a formal
language
![Page 9: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/9.jpg)
Logic is the key• Precise specifications have to be made in a formal
language
• with a rigourous definition of meaning.
![Page 10: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/10.jpg)
Logic is the key• Precise specifications have to be made in a formal
language
• with a rigourous definition of meaning.
• Logic is the “calculus” of computer science.
![Page 11: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/11.jpg)
Logic is the key• Precise specifications have to be made in a formal
language
• with a rigourous definition of meaning.
• Logic is the “calculus” of computer science.
• It comes with a framework for reasoning.
![Page 12: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/12.jpg)
Logic is the key• Precise specifications have to be made in a formal
language
• with a rigourous definition of meaning.
• Logic is the “calculus” of computer science.
• It comes with a framework for reasoning.
• Many kinds of logic: propositional, predicate, modal, .....
![Page 13: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/13.jpg)
Probability
![Page 14: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/14.jpg)
Probability• Probability is also a framework for reasoning
![Page 15: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/15.jpg)
Probability• Probability is also a framework for reasoning
• quantitatively.
![Page 16: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/16.jpg)
Probability• Probability is also a framework for reasoning
• quantitatively.
• But is this relevant for computer programmers?
![Page 17: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/17.jpg)
Probability• Probability is also a framework for reasoning
• quantitatively.
• But is this relevant for computer programmers?
• Yes!
![Page 18: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/18.jpg)
Probability• Probability is also a framework for reasoning
• quantitatively.
• But is this relevant for computer programmers?
• Yes!
• Probabilistic reasoning is everywhere.
![Page 19: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/19.jpg)
Some quotations
![Page 20: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/20.jpg)
Some quotations
• The true logic of the world is the calculus of probabilities — James Clerk Maxwell
![Page 21: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/21.jpg)
Some quotations
• The true logic of the world is the calculus of probabilities — James Clerk Maxwell
• The theory of probabilities is at bottom nothing but common sense reduced to calculus — Pierre Simon Laplace
![Page 22: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/22.jpg)
Why does one use probability?
![Page 23: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/23.jpg)
Why does one use probability?
• Some algorithms use probability as a computational resource: randomized algorithms.
![Page 24: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/24.jpg)
Why does one use probability?
• Some algorithms use probability as a computational resource: randomized algorithms.
• Software for interacting with physical systems have to cope with noise and uncertainty: telecommunications, robotics, vision, control systems, ....
![Page 25: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/25.jpg)
Why does one use probability?
• Some algorithms use probability as a computational resource: randomized algorithms.
• Software for interacting with physical systems have to cope with noise and uncertainty: telecommunications, robotics, vision, control systems, ....
• Big data and machine learning: probabilistic reasoning has had a revolutionary impact.
![Page 26: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/26.jpg)
Basic Ideas
![Page 27: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/27.jpg)
Basic Ideas
Sample space X: the set of things that can
possibly happen.
![Page 28: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/28.jpg)
Basic Ideas
Sample space X: the set of things that can
possibly happen.
Event: subset of the sample space; A,B ⇢ X.
![Page 29: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/29.jpg)
Basic Ideas
Sample space X: the set of things that can
possibly happen.
Event: subset of the sample space; A,B ⇢ X.
Probability: Pr : X ! [0, 1],
Px2X
Pr(x) = 1.
![Page 30: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/30.jpg)
Basic Ideas
Sample space X: the set of things that can
possibly happen.
Event: subset of the sample space; A,B ⇢ X.
Probability: Pr : X ! [0, 1],
Px2X
Pr(x) = 1.
Probability of an event A: Pr(A) =
Px2A
Pr(x).
![Page 31: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/31.jpg)
Basic Ideas
Sample space X: the set of things that can
possibly happen.
Event: subset of the sample space; A,B ⇢ X.
Probability: Pr : X ! [0, 1],
Px2X
Pr(x) = 1.
Probability of an event A: Pr(A) =
Px2A
Pr(x).
A,B are independent: Pr(A \B) = Pr(A) · Pr(B).
![Page 32: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/32.jpg)
Basic Ideas
Sample space X: the set of things that can
possibly happen.
Event: subset of the sample space; A,B ⇢ X.
Probability: Pr : X ! [0, 1],
Px2X
Pr(x) = 1.
Probability of an event A: Pr(A) =
Px2A
Pr(x).
A,B are independent: Pr(A \B) = Pr(A) · Pr(B).
Subprobability:
Px2X
Pr(x) 1.
![Page 33: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/33.jpg)
A Puzzle
![Page 34: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/34.jpg)
A Puzzle
Imagine a town where every birth is equally likely
to give a boy or a girl. Pr(boy) = Pr(girl) = 12 .
![Page 35: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/35.jpg)
A Puzzle
Imagine a town where every birth is equally likely
to give a boy or a girl. Pr(boy) = Pr(girl) = 12 .
Each birth is an independent random event.
![Page 36: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/36.jpg)
A Puzzle
Imagine a town where every birth is equally likely
to give a boy or a girl. Pr(boy) = Pr(girl) = 12 .
Each birth is an independent random event.
There is a family with two children.
![Page 37: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/37.jpg)
A Puzzle
Imagine a town where every birth is equally likely
to give a boy or a girl. Pr(boy) = Pr(girl) = 12 .
Each birth is an independent random event.
There is a family with two children.
One of them is a boy (not specified which one), whatis the probability that the other one is a boy?
![Page 38: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/38.jpg)
A Puzzle
Imagine a town where every birth is equally likely
to give a boy or a girl. Pr(boy) = Pr(girl) = 12 .
Each birth is an independent random event.
There is a family with two children.
One of them is a boy (not specified which one), whatis the probability that the other one is a boy?
Since the births are independent, the probability
that the other child is a boy should be
12 . Right?
![Page 39: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/39.jpg)
Puzzle (continued)
![Page 40: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/40.jpg)
Puzzle (continued)
Wrong!
![Page 41: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/41.jpg)
Puzzle (continued)
Wrong!
Initially, there are 4 equally likely situations:
bb, bg, gb, gg.
![Page 42: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/42.jpg)
Puzzle (continued)
Wrong!
Initially, there are 4 equally likely situations:
bb, bg, gb, gg.
The possibility gg is ruled out with the
additional information.
![Page 43: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/43.jpg)
Puzzle (continued)
Wrong!
Initially, there are 4 equally likely situations:
bb, bg, gb, gg.
The possibility gg is ruled out with the
additional information.
So of the three equally likely scenarios:
bb, bg, gb,
only one has the other child being a boy.
![Page 44: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/44.jpg)
Puzzle (continued)
Wrong!
Initially, there are 4 equally likely situations:
bb, bg, gb, gg.
The possibility gg is ruled out with the
additional information.
So of the three equally likely scenarios:
bb, bg, gb,
only one has the other child being a boy.
The correct answer is
13 .
![Page 45: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/45.jpg)
Puzzle (continued)
Wrong!
Initially, there are 4 equally likely situations:
bb, bg, gb, gg.
The possibility gg is ruled out with the
additional information.
So of the three equally likely scenarios:
bb, bg, gb,
only one has the other child being a boy.
The correct answer is
13 .
If I had said, “The elder child is a boy”, then the probability
that the other child is a boy is indeed
12
![Page 46: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/46.jpg)
Conditional probability
![Page 47: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/47.jpg)
Conditional probability
Conditioning = revising probability in the presence of
new information.
![Page 48: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/48.jpg)
Conditional probability
Conditioning = revising probability in the presence of
new information.
Conditional probability/expectation is the heart of
probabilistic reasoning.
![Page 49: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/49.jpg)
Conditional probability
Conditioning = revising probability in the presence of
new information.
Conditional probability/expectation is the heart of
probabilistic reasoning.
Conditional probability is tricky!
![Page 50: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/50.jpg)
Conditional probability
Conditioning = revising probability in the presence of
new information.
Conditional probability/expectation is the heart of
probabilistic reasoning.
Conditional probability is tricky!
Analogous to inference in ordinary logic.
![Page 51: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/51.jpg)
Conditional probability
![Page 52: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/52.jpg)
Conditional probability
Definition: if A and B are events, the conditional probability
of A given B, written Pr(A | B) is defined by
Pr(A | B) = Pr(A \B)/Pr(B).
![Page 53: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/53.jpg)
Conditional probability
Definition: if A and B are events, the conditional probability
of A given B, written Pr(A | B) is defined by
Pr(A | B) = Pr(A \B)/Pr(B).
We are told that the outcome is one of the possibilities
in B. We now need to change our guess for the outcome
being in A.
![Page 54: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/54.jpg)
Conditional probability
Definition: if A and B are events, the conditional probability
of A given B, written Pr(A | B) is defined by
Pr(A | B) = Pr(A \B)/Pr(B).
We are told that the outcome is one of the possibilities
in B. We now need to change our guess for the outcome
being in A.
A
B
![Page 55: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/55.jpg)
Bayes’ Rule
Pr(A | B) =Pr(B | A) · Pr(A)
Pr(B).
How to revise probabilities.
![Page 56: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/56.jpg)
Bayes’ Rule
Pr(A | B) =Pr(B | A) · Pr(A)
Pr(B).
How to revise probabilities.
Proof is just from the definition.
![Page 57: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/57.jpg)
Example
![Page 58: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/58.jpg)
Example
Two coins, one fake (two heads) one OK.
![Page 59: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/59.jpg)
Example
Two coins, one fake (two heads) one OK.
One coin chosen with equal probability and then tossedto yield a H.
![Page 60: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/60.jpg)
Example
Two coins, one fake (two heads) one OK.
One coin chosen with equal probability and then tossedto yield a H.
What is the probability the coin was fake?
![Page 61: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/61.jpg)
Example
Two coins, one fake (two heads) one OK.
One coin chosen with equal probability and then tossedto yield a H.
What is the probability the coin was fake?
Answer: 23 .
![Page 62: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/62.jpg)
Example
Two coins, one fake (two heads) one OK.
One coin chosen with equal probability and then tossedto yield a H.
What is the probability the coin was fake?
Answer: 23 .
Pr(H | Fake) = 1,Pr(Fake) = 12 ,Pr(H) = 1
2 · 1 + 12 · 1
2 = 34 .
![Page 63: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/63.jpg)
Example
Two coins, one fake (two heads) one OK.
One coin chosen with equal probability and then tossedto yield a H.
What is the probability the coin was fake?
Answer: 23 .
Pr(H | Fake) = 1,Pr(Fake) = 12 ,Pr(H) = 1
2 · 1 + 12 · 1
2 = 34 .
Hence Pr(Fake | H) = ( 12 )/(34 ) =
23 .
![Page 64: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/64.jpg)
Example
Two coins, one fake (two heads) one OK.
One coin chosen with equal probability and then tossedto yield a H.
What is the probability the coin was fake?
Answer: 23 .
Pr(H | Fake) = 1,Pr(Fake) = 12 ,Pr(H) = 1
2 · 1 + 12 · 1
2 = 34 .
Hence Pr(Fake | H) = ( 12 )/(34 ) =
23 .
Similarly Pr(Fake | HHH) = 89 .
![Page 65: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/65.jpg)
Example
Two coins, one fake (two heads) one OK.
One coin chosen with equal probability and then tossedto yield a H.
What is the probability the coin was fake?
Answer: 23 .
Pr(H | Fake) = 1,Pr(Fake) = 12 ,Pr(H) = 1
2 · 1 + 12 · 1
2 = 34 .
Hence Pr(Fake | H) = ( 12 )/(34 ) =
23 .
Similarly Pr(Fake | HHH) = 89 . Pr(Fake | H . . .H| {z }
n
) = 11+( 1
2 )n .
![Page 66: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/66.jpg)
Bayes’ rule shows how to update the prior probability of Awith the new information that the outcome was B: this
gives the posterior probability of A given B.
![Page 67: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/67.jpg)
Expectation values
![Page 68: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/68.jpg)
Expectation values
A random variable r is a real-valued function on X.
![Page 69: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/69.jpg)
Expectation values
A random variable r is a real-valued function on X.
The expectation value of r is E[r] =X
x2X
Pr(x)r(x).
![Page 70: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/70.jpg)
Expectation values
A random variable r is a real-valued function on X.
The expectation value of r is E[r] =X
x2X
Pr(x)r(x).
The conditional expectation value of r given A is:
![Page 71: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/71.jpg)
Expectation values
A random variable r is a real-valued function on X.
The expectation value of r is E[r] =X
x2X
Pr(x)r(x).
The conditional expectation value of r given A is:
E[r | A] =X
x2X
r(x)Pr({x} | A).
![Page 72: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/72.jpg)
Expectation values
A random variable r is a real-valued function on X.
The expectation value of r is E[r] =X
x2X
Pr(x)r(x).
The conditional expectation value of r given A is:
E[r | A] =X
x2X
r(x)Pr({x} | A).
Conditional probability is a special case of
conditional expectation.
![Page 73: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/73.jpg)
Calculating expectations through conditioning
![Page 74: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/74.jpg)
Calculating expectations through conditioning
Two people roll dice independently.
![Page 75: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/75.jpg)
Calculating expectations through conditioning
Two people roll dice independently.
![Page 76: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/76.jpg)
Calculating expectations through conditioning
Two people roll dice independently.
The first one keeps rolling until
he gets a 1 immediately followed by a 2.
![Page 77: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/77.jpg)
Calculating expectations through conditioning
Two people roll dice independently.
The second one keeps rolling
until she gets a 1 and a 1.
The first one keeps rolling until
he gets a 1 immediately followed by a 2.
![Page 78: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/78.jpg)
Calculating expectations through conditioning
Two people roll dice independently.
The second one keeps rolling
until she gets a 1 and a 1.
The first one keeps rolling until
he gets a 1 immediately followed by a 2.
Do they have the same expected number of rolls?
![Page 79: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/79.jpg)
Calculating expectations through conditioning
Two people roll dice independently.
The second one keeps rolling
until she gets a 1 and a 1.
The first one keeps rolling until
he gets a 1 immediately followed by a 2.
Do they have the same expected number of rolls?
If not, who is expected to finish first?
![Page 80: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/80.jpg)
Calculating expectations through conditioning
Two people roll dice independently.
The second one keeps rolling
until she gets a 1 and a 1.
The first one keeps rolling until
he gets a 1 immediately followed by a 2.
Do they have the same expected number of rolls?
If not, who is expected to finish first?
What is the expected number of rolls for each one?
![Page 81: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/81.jpg)
![Page 82: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/82.jpg)
For the first:
16 · (1 + 1
6 · 1 + . . .) + . . .
![Page 83: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/83.jpg)
For the first:
16 · (1 + 1
6 · 1 + . . .) + . . .
Is there a better way?
![Page 84: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/84.jpg)
For the first:
16 · (1 + 1
6 · 1 + . . .) + . . .
Is there a better way?
Use conditional expectations and think in terms of
state-transition diagrams:
![Page 85: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/85.jpg)
For the first:
16 · (1 + 1
6 · 1 + . . .) + . . .
Is there a better way?
Use conditional expectations and think in terms of
state-transition diagrams:
1
3, 4, 5, 6
3, 4, 5, 6
1 2
2,
![Page 86: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/86.jpg)
1
3, 4, 5, 6
3, 4, 5, 6
1 2
2,
![Page 87: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/87.jpg)
Let x = E[Finish | Start]
1
3, 4, 5, 6
3, 4, 5, 6
1 2
2,
![Page 88: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/88.jpg)
Let x = E[Finish | Start] Let y = E[Finish | 1]
1
3, 4, 5, 6
3, 4, 5, 6
1 2
2,
![Page 89: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/89.jpg)
Let x = E[Finish | Start] Let y = E[Finish | 1]
1
3, 4, 5, 6
3, 4, 5, 6
1 2
2,
x = 56 · (1 + x) + 1
6 · (1 + y)
![Page 90: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/90.jpg)
Let x = E[Finish | Start] Let y = E[Finish | 1]
1
3, 4, 5, 6
3, 4, 5, 6
1 2
2,
x = 56 · (1 + x) + 1
6 · (1 + y)
y = 16 · 1 + 1
6 · (1 + y) + 23 · (1 + x)
![Page 91: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/91.jpg)
Let x = E[Finish | Start] Let y = E[Finish | 1]
1
3, 4, 5, 6
3, 4, 5, 6
1 2
2,
x = 56 · (1 + x) + 1
6 · (1 + y)
y = 16 · 1 + 1
6 · (1 + y) + 23 · (1 + x)
Easy to solve: x = 30, y = 36.
![Page 92: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/92.jpg)
1 1
2, 3, 4, 5, 6
2, 3, 4, 5, 6
![Page 93: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/93.jpg)
1 1
2, 3, 4, 5, 6
2, 3, 4, 5, 6
Let x = E[Finish | Start]
![Page 94: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/94.jpg)
1 1
2, 3, 4, 5, 6
2, 3, 4, 5, 6
Let x = E[Finish | Start] Let y = E[Finish | 1]
![Page 95: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/95.jpg)
1 1
2, 3, 4, 5, 6
2, 3, 4, 5, 6
Let x = E[Finish | Start] Let y = E[Finish | 1]
x = 16 · (1 + y) + 5
6 · (1 + x)
![Page 96: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/96.jpg)
1 1
2, 3, 4, 5, 6
2, 3, 4, 5, 6
Let x = E[Finish | Start] Let y = E[Finish | 1]
x = 16 · (1 + y) + 5
6 · (1 + x)
y = 16 · 1 + 5
6 · (1 + x)
![Page 97: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/97.jpg)
1 1
2, 3, 4, 5, 6
2, 3, 4, 5, 6
Let x = E[Finish | Start] Let y = E[Finish | 1]
x = 16 · (1 + y) + 5
6 · (1 + x)
y = 16 · 1 + 5
6 · (1 + x)
Easy to solve: x = 42, y = 36.
![Page 98: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/98.jpg)
1 1
2, 3, 4, 5, 6
2, 3, 4, 5, 6
Let x = E[Finish | Start] Let y = E[Finish | 1]
x = 16 · (1 + y) + 5
6 · (1 + x)
y = 16 · 1 + 5
6 · (1 + x)
Easy to solve: x = 42, y = 36.
Did you expect this to be the slower one?
![Page 99: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/99.jpg)
Understanding programs
![Page 100: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/100.jpg)
Understanding programs
The state of a program is the correspondence between
names and values.
![Page 101: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/101.jpg)
Understanding programs
The state of a program is the correspondence between
names and values.
[X 7! 3, Y 7! 4, Z 7! �2.5]
![Page 102: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/102.jpg)
Understanding programs
The state of a program is the correspondence between
names and values.
Running a part of a program changes the state.
[X 7! 3, Y 7! 4, Z 7! �2.5]
![Page 103: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/103.jpg)
Understanding programs
The state of a program is the correspondence between
names and values.
Running a part of a program changes the state.
[X 7! 3, Y 7! 4, Z 7! �2.5]
if X > 1 then Y = Y + Z else Y = Z
![Page 104: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/104.jpg)
Understanding programs
The state of a program is the correspondence between
names and values.
Running a part of a program changes the state.
[X 7! 3, Y 7! 4, Z 7! �2.5]
if X > 1 then Y = Y + Z else Y = Z
[X 7! 3, Y 7! 4, Z 7! �2.5] �! [X 7! 3, Y 7! 1.5, Z 7! �2.5]
![Page 105: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/105.jpg)
Understanding programs
The state of a program is the correspondence between
names and values.
Running a part of a program changes the state.
[X 7! 3, Y 7! 4, Z 7! �2.5]
if X > 1 then Y = Y + Z else Y = Z
[X 7! 3, Y 7! 4, Z 7! �2.5] �! [X 7! 3, Y 7! 1.5, Z 7! �2.5]
Ordinary programs define state-transformer functions.
![Page 106: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/106.jpg)
Understanding programs
The state of a program is the correspondence between
names and values.
Running a part of a program changes the state.
[X 7! 3, Y 7! 4, Z 7! �2.5]
if X > 1 then Y = Y + Z else Y = Z
[X 7! 3, Y 7! 4, Z 7! �2.5] �! [X 7! 3, Y 7! 1.5, Z 7! �2.5]
Ordinary programs define state-transformer functions.
When one combines program pieces one can
compose the functions to find the combined e↵ect.
![Page 107: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/107.jpg)
Understanding programs
The state of a program is the correspondence between
names and values.
Running a part of a program changes the state.
[X 7! 3, Y 7! 4, Z 7! �2.5]
if X > 1 then Y = Y + Z else Y = Z
[X 7! 3, Y 7! 4, Z 7! �2.5] �! [X 7! 3, Y 7! 1.5, Z 7! �2.5]
Ordinary programs define state-transformer functions.
How do we understand probabilistic programs?
When one combines program pieces one can
compose the functions to find the combined e↵ect.
![Page 108: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/108.jpg)
Understanding programs
The state of a program is the correspondence between
names and values.
Running a part of a program changes the state.
[X 7! 3, Y 7! 4, Z 7! �2.5]
if X > 1 then Y = Y + Z else Y = Z
[X 7! 3, Y 7! 4, Z 7! �2.5] �! [X 7! 3, Y 7! 1.5, Z 7! �2.5]
Ordinary programs define state-transformer functions.
How do we understand probabilistic programs?
As distribution transformers.
When one combines program pieces one can
compose the functions to find the combined e↵ect.
![Page 109: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/109.jpg)
X = 0; C = toss; if C = 1 then X = X + 1 else X = X � 1.
![Page 110: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/110.jpg)
X = 0; C = toss; if C = 1 then X = X + 1 else X = X � 1.
Initial distribution: [X 7! (0, 1.0), C 7! (0, 1.0)]
![Page 111: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/111.jpg)
X = 0; C = toss; if C = 1 then X = X + 1 else X = X � 1.
Initial distribution: [X 7! (0, 1.0), C 7! (0, 1.0)]
Final distribution: [X 7! (1, 0.5)(�1, 0.5), C 7! (0, 0.5)(1, 0.5)]
![Page 112: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/112.jpg)
X = 0; C = toss; if C = 1 then X = X + 1 else X = X � 1.
Initial distribution: [X 7! (0, 1.0), C 7! (0, 1.0)]
Final distribution: [X 7! (1, 0.5)(�1, 0.5), C 7! (0, 0.5)(1, 0.5)]
A Markov chain has S: states and a probability
distribution transformer T .
![Page 113: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/113.jpg)
X = 0; C = toss; if C = 1 then X = X + 1 else X = X � 1.
Initial distribution: [X 7! (0, 1.0), C 7! (0, 1.0)]
Final distribution: [X 7! (1, 0.5)(�1, 0.5), C 7! (0, 0.5)(1, 0.5)]
A Markov chain has S: states and a probability
distribution transformer T .
T : St⇥ St ! [0, 1] or T : St ! Dist(St).
![Page 114: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/114.jpg)
X = 0; C = toss; if C = 1 then X = X + 1 else X = X � 1.
Initial distribution: [X 7! (0, 1.0), C 7! (0, 1.0)]
Final distribution: [X 7! (1, 0.5)(�1, 0.5), C 7! (0, 0.5)(1, 0.5)]
A Markov chain has S: states and a probability
distribution transformer T .
T : St⇥ St ! [0, 1] or T : St ! Dist(St).
T (s1, s2) is the conditional probability of being
in state s2 after the transition given that the
state was s1 before.
![Page 115: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/115.jpg)
X = 0; C = toss; if C = 1 then X = X + 1 else X = X � 1.
Initial distribution: [X 7! (0, 1.0), C 7! (0, 1.0)]
Final distribution: [X 7! (1, 0.5)(�1, 0.5), C 7! (0, 0.5)(1, 0.5)]
A Markov chain has S: states and a probability
distribution transformer T .
T : St⇥ St ! [0, 1] or T : St ! Dist(St).
T (s1, s2) is the conditional probability of being
in state s2 after the transition given that the
state was s1 before.
Markov property: the transition probability only depends
on the current state, not on the whole history.
![Page 116: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/116.jpg)
Because of the Markov property, one can describe
the e↵ect of a transition by a matrix.
![Page 117: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/117.jpg)
Because of the Markov property, one can describe
the e↵ect of a transition by a matrix.
When one combines probabilistic program pieces
one can multiply the transition matrices to find
the combined e↵ect.
![Page 118: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/118.jpg)
Because of the Markov property, one can describe
the e↵ect of a transition by a matrix.
When one combines probabilistic program pieces
one can multiply the transition matrices to find
the combined e↵ect.
We are understanding the program by stepping forwards.
![Page 119: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/119.jpg)
Because of the Markov property, one can describe
the e↵ect of a transition by a matrix.
When one combines probabilistic program pieces
one can multiply the transition matrices to find
the combined e↵ect.
We are understanding the program by stepping forwards.
This is called “forwards” or state-transformer semantics.
![Page 120: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/120.jpg)
Backwards semantics
![Page 121: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/121.jpg)
Maybe we do not want to track every detail of the state
as it changes.
Backwards semantics
![Page 122: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/122.jpg)
Maybe we do not want to track every detail of the state
as it changes.
Backwards semantics
Perhaps we want to know if a property holds,
e.g. X > 0.
![Page 123: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/123.jpg)
Maybe we do not want to track every detail of the state
as it changes.
Backwards semantics
Perhaps we want to know if a property holds,
e.g. X > 0.
We write {P} step {Q} to mean that P holds
before the step and Q holds after the step.
![Page 124: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/124.jpg)
Maybe we do not want to track every detail of the state
as it changes.
Backwards semantics
Perhaps we want to know if a property holds,
e.g. X > 0.
We write {P} step {Q} to mean that P holds
before the step and Q holds after the step.
{X > 0} X = X � 5 {X > 0} ??
![Page 125: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/125.jpg)
Maybe we do not want to track every detail of the state
as it changes.
Backwards semantics
Perhaps we want to know if a property holds,
e.g. X > 0.
We write {P} step {Q} to mean that P holds
before the step and Q holds after the step.
{X > 0} X = X � 5 {X > 0} ??
We cannot say anything for sure after the step!
![Page 126: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/126.jpg)
But we can go backwards!
![Page 127: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/127.jpg)
But we can go backwards!
{X > 5} X = X � 5 {X > 0}
![Page 128: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/128.jpg)
But we can go backwards!
{X > 5} X = X � 5 {X > 0} �
![Page 129: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/129.jpg)
But we can go backwards!
{X > 5} X = X � 5 {X > 0}
We must read this di↵erently: if we want X > 0
after the step, we must make sure X > 5 before the step.
�
![Page 130: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/130.jpg)
But we can go backwards!
{X > 5} X = X � 5 {X > 0}
We must read this di↵erently: if we want X > 0
after the step, we must make sure X > 5 before the step.
This is called “predicate-transformer” semantics.
�
![Page 131: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/131.jpg)
But we can go backwards!
{X > 5} X = X � 5 {X > 0}
We must read this di↵erently: if we want X > 0
after the step, we must make sure X > 5 before the step.
This is called “predicate-transformer” semantics.
�
Can we do something like this for probabilistic programs?
![Page 132: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/132.jpg)
Classical logic Generalization
Truth values {0, 1} Probabilities [0, 1]Predicate Random variable
State Distribution
The satisfaction relation |= Integration
R
![Page 133: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/133.jpg)
Instead of predicates we have real-valued functions.
![Page 134: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/134.jpg)
Instead of predicates we have real-valued functions.
Suppose that your probabilistic program describes a
search for some resource.
![Page 135: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/135.jpg)
Instead of predicates we have real-valued functions.
Suppose that your probabilistic program describes a
search for some resource.
Suppose that r : St ! R is the “expected reward”
in each state.
![Page 136: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/136.jpg)
Instead of predicates we have real-valued functions.
Suppose that your probabilistic program describes a
search for some resource.
Suppose that r : St ! R is the “expected reward”
in each state.
We write
ˆTr for a new reward function defined by
(
ˆTr)(s) =X
s02S
T (s, s0)r(s0).
![Page 137: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/137.jpg)
Instead of predicates we have real-valued functions.
Suppose that your probabilistic program describes a
search for some resource.
Suppose that r : St ! R is the “expected reward”
in each state.
We write
ˆTr for a new reward function defined by
(
ˆTr)(s) =X
s02S
T (s, s0)r(s0).
This tells you the expected reward before the transition
assuming that r is the reward after the transition.
![Page 138: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/138.jpg)
Probabilistic Models
![Page 139: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/139.jpg)
Probabilistic Models
• A general framework to reason about situations computationally and quantitatively.
![Page 140: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/140.jpg)
Probabilistic Models
• A general framework to reason about situations computationally and quantitatively.
• Most important class of models: graphical models.
![Page 141: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/141.jpg)
Probabilistic Models
• A general framework to reason about situations computationally and quantitatively.
• Most important class of models: graphical models.
• They capture dependence and independence and
![Page 142: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/142.jpg)
Probabilistic Models
• A general framework to reason about situations computationally and quantitatively.
• Most important class of models: graphical models.
• They capture dependence and independence and
• conditional independence.
![Page 143: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/143.jpg)
Complex systems
![Page 144: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/144.jpg)
Complex systems• Complex systems have many variables.
![Page 145: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/145.jpg)
Complex systems• Complex systems have many variables.
• They are related in intricate ways: correlated or independent.
![Page 146: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/146.jpg)
Complex systems• Complex systems have many variables.
• They are related in intricate ways: correlated or independent.
• They may be conditionally independent or dependent.
![Page 147: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/147.jpg)
Complex systems• Complex systems have many variables.
• They are related in intricate ways: correlated or independent.
• They may be conditionally independent or dependent.
• There may be causal connections.
![Page 148: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/148.jpg)
Complex systems• Complex systems have many variables.
• They are related in intricate ways: correlated or independent.
• They may be conditionally independent or dependent.
• There may be causal connections.
• We want to represent several random variables that may be connected in different ways.
![Page 149: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/149.jpg)
A simple graphical model
![Page 150: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/150.jpg)
A simple graphical model
Trying to analyze what is wrong with a web site:
![Page 151: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/151.jpg)
A simple graphical model
Trying to analyze what is wrong with a web site:
could be buggy (yes/no)
![Page 152: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/152.jpg)
A simple graphical model
Trying to analyze what is wrong with a web site:
could be buggy (yes/no)
could be under attack (yes/no)
![Page 153: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/153.jpg)
A simple graphical model
Trying to analyze what is wrong with a web site:
could be buggy (yes/no)
could be under attack (yes/no)
tra�c (very high/high/moderate/low)
![Page 154: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/154.jpg)
A simple graphical model
Trying to analyze what is wrong with a web site:
could be buggy (yes/no)
could be under attack (yes/no)
tra�c (very high/high/moderate/low)
Symptoms: crashed or slow
![Page 155: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/155.jpg)
A simple graphical model
Trying to analyze what is wrong with a web site:
could be buggy (yes/no)
could be under attack (yes/no)
tra�c (very high/high/moderate/low)
Symptoms: crashed or slow
There are 64 states.
![Page 156: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/156.jpg)
![Page 157: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/157.jpg)
The arrows show probabilistic dependencies.
![Page 158: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/158.jpg)
The arrows show probabilistic dependencies.
Everything in the top row is independent of each other.
![Page 159: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/159.jpg)
The arrows show probabilistic dependencies.
Everything in the top row is independent of each other.
We write A?B for A is independent of B.
![Page 160: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/160.jpg)
The arrows show probabilistic dependencies.
Everything in the top row is independent of each other.
We write A?B for A is independent of B.
Perhaps too simple:
if attacked then the tra�c should be heavy.
![Page 161: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/161.jpg)
This version: tra�c is a↵ected by being attacked.
![Page 162: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/162.jpg)
Medical example (from Koller and Friedman)
![Page 163: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/163.jpg)
Medical example (from Koller and Friedman)
Flu and allergy are correlated through season.
![Page 164: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/164.jpg)
Medical example (from Koller and Friedman)
Flu and allergy are correlated through season.
Given the season, they are independent: (A?F | S)
![Page 165: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/165.jpg)
![Page 166: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/166.jpg)
Independence relations:
![Page 167: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/167.jpg)
Independence relations:
(F?A | S), (Sn?S | F,A), (P?A,Sn | F ), (P | Sn | F )
![Page 168: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/168.jpg)
Independence relations:
(F?A | S), (Sn?S | F,A), (P?A,Sn | F ), (P | Sn | F )
P (Sn | F,A, S) = P (Sn | F,A)
![Page 169: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/169.jpg)
Independence relations:
(F?A | S), (Sn?S | F,A), (P?A,Sn | F ), (P | Sn | F )
P (Sn | F,A, S) = P (Sn | F,A)
Sn depends on S but it is conditionally independent given A and F .
![Page 170: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/170.jpg)
Independence and Factorization
![Page 171: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/171.jpg)
Independence and Factorization
Why do we care about conditional independence?
![Page 172: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/172.jpg)
Independence and Factorization
Why do we care about conditional independence?
Because we can factorize the joint distributions.
![Page 173: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/173.jpg)
Independence and Factorization
Why do we care about conditional independence?
Because we can factorize the joint distributions.
![Page 174: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/174.jpg)
Independence and Factorization
Why do we care about conditional independence?
Because we can factorize the joint distributions.
P (S,A, F, P, Sn) =
P (S)P (F |S)P (A|S)P (Sn|A,F )P (Pain|F )
![Page 175: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/175.jpg)
Independence and Factorization
Why do we care about conditional independence?
Because we can factorize the joint distributions.
P (S,A, F, P, Sn) =
P (S)P (F |S)P (A|S)P (Sn|A,F )P (Pain|F )
A huge advantage for representing, computing and reasoning.
![Page 176: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/176.jpg)
Where can we go from here?
![Page 177: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/177.jpg)
Where can we go from here?
Continuous state spaces: robotics, telecommunication,
control systems, sensor systems.
![Page 178: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/178.jpg)
Where can we go from here?
Continuous state spaces: robotics, telecommunication,
control systems, sensor systems.
Requires measure theory and analysis.
![Page 179: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/179.jpg)
Where can we go from here?
Continuous state spaces: robotics, telecommunication,
control systems, sensor systems.
Requires measure theory and analysis. Why?
![Page 180: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/180.jpg)
Where can we go from here?
Continuous state spaces: robotics, telecommunication,
control systems, sensor systems.
Requires measure theory and analysis. Why?
It is subtle to answer questions like:
![Page 181: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/181.jpg)
Where can we go from here?
Continuous state spaces: robotics, telecommunication,
control systems, sensor systems.
Requires measure theory and analysis. Why?
It is subtle to answer questions like:
I choose a real number between 0 and 1 uniformly, what is the probability of
getting a rational number?
![Page 182: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/182.jpg)
Where can we go from here?
Continuous state spaces: robotics, telecommunication,
control systems, sensor systems.
Requires measure theory and analysis. Why?
It is subtle to answer questions like:
I choose a real number between 0 and 1 uniformly, what is the probability of
getting a rational number? Answer: 0!
![Page 183: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/183.jpg)
Where can we go from here?
Continuous state spaces: robotics, telecommunication,
control systems, sensor systems.
Requires measure theory and analysis. Why?
It is subtle to answer questions like:
I choose a real number between 0 and 1 uniformly, what is the probability of
getting a rational number? Answer: 0!
If every single point has probability 0 how can I have anything interesting?
![Page 184: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/184.jpg)
Where can we go from here?
Continuous state spaces: robotics, telecommunication,
control systems, sensor systems.
Requires measure theory and analysis. Why?
It is subtle to answer questions like:
I choose a real number between 0 and 1 uniformly, what is the probability of
getting a rational number? Answer: 0!
If every single point has probability 0 how can I have anything interesting?
Is it possible to assign a probability to every set?
![Page 185: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/185.jpg)
Where can we go from here?
Continuous state spaces: robotics, telecommunication,
control systems, sensor systems.
Requires measure theory and analysis. Why?
It is subtle to answer questions like:
I choose a real number between 0 and 1 uniformly, what is the probability of
getting a rational number? Answer: 0!
If every single point has probability 0 how can I have anything interesting?
Is it possible to assign a probability to every set?
Answer: No!
![Page 186: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/186.jpg)
Where can we go from here?
Continuous state spaces: robotics, telecommunication,
control systems, sensor systems.
Requires measure theory and analysis. Why?
It is subtle to answer questions like:
I choose a real number between 0 and 1 uniformly, what is the probability of
getting a rational number? Answer: 0!
If every single point has probability 0 how can I have anything interesting?
Is it possible to assign a probability to every set?
Answer: No!
There is a rich and fascinating theory of programming
and reasoning about probabilistic systems.
![Page 187: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/187.jpg)
Logic and Probability are your weapons.
Go forth and conquer the software world!
![Page 188: Probability in Programmingprakash/Talks/tsd.pdf · 2015-05-14 · Why does one use probability? • Some algorithms use probability as a computational resource: randomized algorithms](https://reader033.vdocument.in/reader033/viewer/2022050313/5f75c3aa4d46ca24d1477d6c/html5/thumbnails/188.jpg)
Thank you!