bayes in practice & random variables · 2011. 8. 29. · probability assignment in bernoulli...

17
Bayes in Practice & Random Variables stat 430 Heike Hofmann

Upload: others

Post on 09-Dec-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Bayes in Practice & Random Variables · 2011. 8. 29. · Probability assignment in Bernoulli Spaces •If experiments are independent: •For sequence s in sample space P(s) = pi

Bayes in Practice & Random Variables

stat 430Heike Hofmann

Page 2: Bayes in Practice & Random Variables · 2011. 8. 29. · Probability assignment in Bernoulli Spaces •If experiments are independent: •For sequence s in sample space P(s) = pi

Outline

• Bernoulli Experiments

• Discrete Random Variables

• Expected Value

Page 3: Bayes in Practice & Random Variables · 2011. 8. 29. · Probability assignment in Bernoulli Spaces •If experiments are independent: •For sequence s in sample space P(s) = pi

Bayes

Page 4: Bayes in Practice & Random Variables · 2011. 8. 29. · Probability assignment in Bernoulli Spaces •If experiments are independent: •For sequence s in sample space P(s) = pi

Tree DiagramsVisualization of Total Probability

24 CHAPTER 1. INTRODUCTION

B1 A B1P(A| B1)

B2 A B2P(A| B2)

Bk A BkP(A| Bk)

The probability of each node in the tree can be calculated by mul-tiplying all probabilities from the root to the event (1st rule of treediagrams).Summing up all the probabilities in the leaves gives P (A) (2ndrule).

Homework: Powerball - with the PowerballRedo the above analysis under the assumption that besides the five numbers chosen from 1 to 49 you choosean additional number, again, between 1 and 49 as the Powerball. The Powerball may be a number you’vealready chosen or a new one.You’ve won, if at least the Powerball is the right number or, if the Powerball is wrong, at least three out ofthe other five numbers must match.

• Show that the events “Powerball is right”, “Powerball is wrong”is a cover of the sample space (for that,you need to define a sample space).

• Draw a tree diagram for all possible ways to win, given that the Powerball is right or wrong.

• What is the probability to win?

Extra Problem (tricky): Seven Lamps

A system of seven lamps is given as drawn in the diagram.

Each lamp fails (independently) with probability p = 0.1.The system works as long as not two lamps next to each other fail.What is the probability that the system works?

Example 1.7.2 Forensic AnalysisOn a crime site the police found traces of DNA (evidence DNA), which could be identified to belong to theperpetrator. Now, the search is done by looking for a DNA match.The probability for ”a man from the street” to have the same DNA as the DNA from the crime site (randommatch) is approx. 1: 1 Mio.For the analysis, whether someone is a DNA match or not, a test is used. The test is not totally reliable,but if a person is a true DNA match, the test will be positive with a probability of 1. If the person is not aDNA match, the test will still be positive with a probability of 1:100000.Assuming, that the police found a man with a positive test result. What is the probability that he actuallyis a DNA match?First, we have to formulate the above text into probability statements.The probability for a random match is

P ( match ) = 1 : 1 Mio = 10−6.

cover

P(B1)

P(B2)

P(Bk)

The probability of a node is given as the product of all

probabilities along the edges back to the root (Definition of conditional probability)

The probability of an event is the sum of the

probabilities of all final nodes (leaves) involved

Page 5: Bayes in Practice & Random Variables · 2011. 8. 29. · Probability assignment in Bernoulli Spaces •If experiments are independent: •For sequence s in sample space P(s) = pi

B1, B2, B3, ...

If the set B1, . . . , Bk is a cover of the sample space Ω, we can compute the probabilityfor an event A by (cf. fig.??):

P (A) =k

i=1

P (Bi) · P (A|Bi).

P (Bj |A) =P (Bj ∩A)

P (A)=

P (A|Bj) · P (Bj)ki=1 P (A|Bi) · P (Bi)

for all j and ∅ = A ⊂ Ω.

7

B1, B2, B3, ...

If the set B1, . . . , Bk is a cover of the sample space Ω, we can compute the probabilityfor an event A by (cf. fig.??):

P (A) =k

i=1

P (Bi) · P (A|Bi).

P (Bj |A) =P (Bj ∩A)

P (A)=

P (A|Bj) · P (Bj)ki=1 P (A|Bi) · P (Bi)

for all j and ∅ = A ⊂ Ω.

7

Bayes’ Rule

• Bayes TheoremLet be a cover of the sample space, then

Page 6: Bayes in Practice & Random Variables · 2011. 8. 29. · Probability assignment in Bernoulli Spaces •If experiments are independent: •For sequence s in sample space P(s) = pi

Example: Forensic AnalysisSetup: DNA is found at a crime scene

Probability for a (random) DNA match is I in10 MioDNA test procedure is sometimes faulty: false negative: P(test neg | match) = 0.0000001 false positive: P(test pos | no match) = 0.000001

Assume, police has a positive test result from a suspect. What is the probability that they have found the perpetrator?

Page 7: Bayes in Practice & Random Variables · 2011. 8. 29. · Probability assignment in Bernoulli Spaces •If experiments are independent: •For sequence s in sample space P(s) = pi

Example: Monty Hall Problem

Setup:- Two goats and one car behind doors- Game show contestant has to pick a door (but doesn’t open it yet)- Host reveals one of the goats- Final choice for contestant: stick with original pick or switch to the other door?

What is the probability of winning the car?

Page 8: Bayes in Practice & Random Variables · 2011. 8. 29. · Probability assignment in Bernoulli Spaces •If experiments are independent: •For sequence s in sample space P(s) = pi

Bernoulli & Binomial

Page 9: Bayes in Practice & Random Variables · 2011. 8. 29. · Probability assignment in Bernoulli Spaces •If experiments are independent: •For sequence s in sample space P(s) = pi

Bernoulli Experiments

• Outcome: success or failure; 0 or 1

• P(success) = p, P(failure) = 1 - p

• sequence of (independent) repetitions: sequence of Bernoulli experiments

Page 10: Bayes in Practice & Random Variables · 2011. 8. 29. · Probability assignment in Bernoulli Spaces •If experiments are independent: •For sequence s in sample space P(s) = pi

Sequence of Bernoulli Experiments

• k repetitions of Bernoulli experiment:

• Write sample space as sequence of k-digit binary numbers:

V ar[X] =

i

(xi − E[X])2 · pX(xi)

The function pX(x) := P (X = x) is called the probability mass function of X. Aprobability mass function has two main properties: Properties of a pmf pX is the pmf ofX, if and only if

(i) all values must be between 0 and 1 0 ≤ pX(x) ≤ 1 for all x ∈ x1, x2, x3, . . .

(ii) the sum of all values is 1

i pX(xi) = 1

E[h(X)] =

i

h(xi) · pX(xi) =: µ

Ωk = 00...00, 00...01, 00...10, 00...11,

...,

11...00, 11...01, 11...10, 11...11

A function X : Ω → R is called a random variable.

k

i

P (X = k) =

n

k

pk(1− p)n−k

(i) 0 ≤ P (A) ≤ 1

(ii) P (∅) = 0

(iii) for pairwise disjoint events A1, A2, A3, ...

P (A1 ∪A2 ∪A3 ∪ ...) = P (A1) + P (A2) + P (A3) + ...

P (Ω) = 1

P (A) = 1− P (A)

P (A ∪B) = P (A) + P (B)− P (A ∩B)

Ω1 =

(1, 1), (1, 2) ... (1, 6)(2, 1), (2, 2) ... (2, 6)

......

. . ....

(6, 1), (6, 2) ... (6, 6)

5

Page 11: Bayes in Practice & Random Variables · 2011. 8. 29. · Probability assignment in Bernoulli Spaces •If experiments are independent: •For sequence s in sample space P(s) = pi

Probability assignment in Bernoulli Spaces• If experiments are independent:

• For sequence s in sample space P(s) = pi (1-p)k-i

if s has i successes and k-i failures.(Hint: substitute 0s by 1-p and 1s by p)

• # of sequences with exactly i successes is

V ar[X] =

i

(xi − E[X])2 · pX(xi)

The function pX(x) := P (X = x) is called the probability mass function of X. Aprobability mass function has two main properties: Properties of a pmf pX is the pmf ofX, if and only if

(i) all values must be between 0 and 1 0 ≤ pX(x) ≤ 1 for all x ∈ x1, x2, x3, . . .

(ii) the sum of all values is 1

i pX(xi) = 1

E[h(X)] =

i

h(xi) · pX(xi) =: µ

Ωk = 00...00, 00...01, 00...10, 00...11,

...,

11...00, 11...01, 11...10, 11...11

A function X : Ω → R is called a random variable.

k

i

P (X = k) =

n

k

pk(1− p)n−k

(i) 0 ≤ P (A) ≤ 1

(ii) P (∅) = 0

(iii) for pairwise disjoint events A1, A2, A3, ...

P (A1 ∪A2 ∪A3 ∪ ...) = P (A1) + P (A2) + P (A3) + ...

P (Ω) = 1

P (A) = 1− P (A)

P (A ∪B) = P (A) + P (B)− P (A ∩B)

Ω1 =

(1, 1), (1, 2) ... (1, 6)(2, 1), (2, 2) ... (2, 6)

......

. . ....

(6, 1), (6, 2) ... (6, 6)

5

Page 12: Bayes in Practice & Random Variables · 2011. 8. 29. · Probability assignment in Bernoulli Spaces •If experiments are independent: •For sequence s in sample space P(s) = pi

V ar[X] =

i

(xi − E[X])2 · pX(xi)

The function pX(x) := P (X = x) is called the probability mass function of X. Aprobability mass function has two main properties: Properties of a pmf pX is the pmf ofX, if and only if

(i) all values must be between 0 and 1 0 ≤ pX(x) ≤ 1 for all x ∈ x1, x2, x3, . . .

(ii) the sum of all values is 1

i pX(xi) = 1

E[h(X)] =

i

h(xi) · pX(xi) =: µ

Ωk = 00...00, 00...01, 00...10, 00...11,

...,

11...00, 11...01, 11...10, 11...11

A function X : Ω → R is called a random variable.

k

i

P (X = k) =

n

k

pk(1− p)n−k

(i) 0 ≤ P (A) ≤ 1

(ii) P (∅) = 0

(iii) for pairwise disjoint events A1, A2, A3, ...

P (A1 ∪A2 ∪A3 ∪ ...) = P (A1) + P (A2) + P (A3) + ...

P (Ω) = 1

P (A) = 1− P (A)

P (A ∪B) = P (A) + P (B)− P (A ∩B)

Ω1 =

(1, 1), (1, 2) ... (1, 6)(2, 1), (2, 2) ... (2, 6)

......

. . ....

(6, 1), (6, 2) ... (6, 6)

5

Binomial distribution

• Let X be the number of successes in n independent Bernoulli experiments with P(success)=p,

• then

Page 13: Bayes in Practice & Random Variables · 2011. 8. 29. · Probability assignment in Bernoulli Spaces •If experiments are independent: •For sequence s in sample space P(s) = pi

V ar[X] =

i

(xi − E[X])2 · pX(xi)

The function pX(x) := P (X = x) is called the probability mass function of X. Aprobability mass function has two main properties: Properties of a pmf pX is the pmf ofX, if and only if

(i) all values must be between 0 and 1 0 ≤ pX(x) ≤ 1 for all x ∈ x1, x2, x3, . . .

(ii) the sum of all values is 1

i pX(xi) = 1

E[h(X)] =

i

h(xi) · pX(xi) =: µ

Ωk = 00...00, 00...01, 00...10, 00...11,

...,

11...00, 11...01, 11...10, 11...11

A function X : Ω → R is called a random variable.

k

i

P (X = k) =

n

k

pk(1− p)n−k

(i) 0 ≤ P (A) ≤ 1

(ii) P (∅) = 0

(iii) for pairwise disjoint events A1, A2, A3, ...

P (A1 ∪A2 ∪A3 ∪ ...) = P (A1) + P (A2) + P (A3) + ...

P (Ω) = 1

P (A) = 1− P (A)

P (A ∪B) = P (A) + P (B)− P (A ∩B)

Ω1 =

(1, 1), (1, 2) ... (1, 6)(2, 1), (2, 2) ... (2, 6)

......

. . ....

(6, 1), (6, 2) ... (6, 6)

5

Random Variables• Definition:

A function is called a random variable

• image of X: im(X) = X(Omega) = set of all possible values X can take

Examples: #heads in 10 throws, #of songs from 80s in 1h of LITE 104.1 (or KURE 88.5 FM), winnings in Darts

Page 14: Bayes in Practice & Random Variables · 2011. 8. 29. · Probability assignment in Bernoulli Spaces •If experiments are independent: •For sequence s in sample space P(s) = pi

Discrete R.V.s

• If the image of a random variable is finite (or countable infinite), the random variable is a discrete variable

• probability mass function

Page 15: Bayes in Practice & Random Variables · 2011. 8. 29. · Probability assignment in Bernoulli Spaces •If experiments are independent: •For sequence s in sample space P(s) = pi

V ar[X] =

i

(xi − E[X])2 · pX(xi)

The function pX(x) := P (X = x) is called the probability mass function of X. Aprobability mass function has two main properties: Properties of a pmf pX is the pmf ofX, if and only if

(i) all values must be between 0 and 1 0 ≤ pX(x) ≤ 1 for all x ∈ x1, x2, x3, . . .

(ii) the sum of all values is 1

i pX(xi) = 1

E[h(X)] =

i

h(xi) · pX(xi) =: µ

Ωk = 00...00, 00...01, 00...10, 00...11,

...,

11...00, 11...01, 11...10, 11...11

A function X : Ω → R is called a random variable.

k

i

P (X = k) =

n

k

pk(1− p)n−k

(i) 0 ≤ P (A) ≤ 1

(ii) P (∅) = 0

(iii) for pairwise disjoint events A1, A2, A3, ...

P (A1 ∪A2 ∪A3 ∪ ...) = P (A1) + P (A2) + P (A3) + ...

P (Ω) = 1

P (A) = 1− P (A)

P (A ∪B) = P (A) + P (B)− P (A ∩B)

Ω1 =

(1, 1), (1, 2) ... (1, 6)(2, 1), (2, 2) ... (2, 6)

......

. . ....

(6, 1), (6, 2) ... (6, 6)

5

V ar[X] =

i

(xi − E[X])2 · pX(xi)

The function pX(x) := P (X = x) is called the probability mass function of X. Aprobability mass function has two main properties: Properties of a pmf pX is the pmf ofX, if and only if

(i) all values must be between 0 and 1 0 ≤ pX(x) ≤ 1 for all x ∈ x1, x2, x3, . . .

(ii) the sum of all values is 1

i pX(xi) = 1

E[h(X)] =

i

h(xi) · pX(xi) =: µ

Ωk = 00...00, 00...01, 00...10, 00...11,

...,

11...00, 11...01, 11...10, 11...11

A function X : Ω → R is called a random variable.

k

i

P (X = k) =

n

k

pk(1− p)n−k

(i) 0 ≤ P (A) ≤ 1

(ii) P (∅) = 0

(iii) for pairwise disjoint events A1, A2, A3, ...

P (A1 ∪A2 ∪A3 ∪ ...) = P (A1) + P (A2) + P (A3) + ...

P (Ω) = 1

P (A) = 1− P (A)

P (A ∪B) = P (A) + P (B)− P (A ∩B)

Ω1 =

(1, 1), (1, 2) ... (1, 6)(2, 1), (2, 2) ... (2, 6)

......

. . ....

(6, 1), (6, 2) ... (6, 6)

5

Probability mass function (pmf)

• Theorem: pX is a pmf, iff

• 0 ≤ pX(x) ≤ 1 for all x in im(X)

• for im(X) = x1, x2, ...

Page 16: Bayes in Practice & Random Variables · 2011. 8. 29. · Probability assignment in Bernoulli Spaces •If experiments are independent: •For sequence s in sample space P(s) = pi

Expectation

Page 17: Bayes in Practice & Random Variables · 2011. 8. 29. · Probability assignment in Bernoulli Spaces •If experiments are independent: •For sequence s in sample space P(s) = pi

Expected Value

• The expected value of random variable X is the long term average that we will see, when we repeat the same experiment over and over:

• for additional function h, we get:

V ar[X] =

i

(xi − E[X])2 · pX(xi)

The function pX(x) := P (X = x) is called the probability mass function of X. Aprobability mass function has two main properties: Properties of a pmf pX is the pmf ofX, if and only if

(i) all values must be between 0 and 1 0 ≤ pX(x) ≤ 1 for all x ∈ x1, x2, x3, . . .

(ii) the sum of all values is 1

i pX(xi) = 1

E[h(X)] =

i

h(xi) · pX(xi) =: µ

Ωk = 00...00, 00...01, 00...10, 00...11,

...,

11...00, 11...01, 11...10, 11...11

A function X : Ω → R is called a random variable.

k

i

P (X = k) =

n

k

pk(1− p)n−k

(i) 0 ≤ P (A) ≤ 1

(ii) P (∅) = 0

(iii) for pairwise disjoint events A1, A2, A3, ...

P (A1 ∪A2 ∪A3 ∪ ...) = P (A1) + P (A2) + P (A3) + ...

P (Ω) = 1

P (A) = 1− P (A)

P (A ∪B) = P (A) + P (B)− P (A ∩B)

Ω1 =

(1, 1), (1, 2) ... (1, 6)(2, 1), (2, 2) ... (2, 6)

......

. . ....

(6, 1), (6, 2) ... (6, 6)

5

V ar[X] =

i

(xi − E[X])2 · pX(xi)

The function pX(x) := P (X = x) is called the probability mass function of X. Aprobability mass function has two main properties: Properties of a pmf pX is the pmf ofX, if and only if

(i) all values must be between 0 and 1 0 ≤ pX(x) ≤ 1 for all x ∈ x1, x2, x3, . . .

(ii) the sum of all values is 1

i pX(xi) = 1

E[h(X)] =

i

h(xi) · pX(xi) =: µ

E[X] =

i

xi · pX(xi) =: µ

Ωk = 00...00, 00...01, 00...10, 00...11,

...,

11...00, 11...01, 11...10, 11...11

A function X : Ω → R is called a random variable.

k

i

P (X = k) =

n

k

pk(1− p)n−k

(i) 0 ≤ P (A) ≤ 1

(ii) P (∅) = 0

(iii) for pairwise disjoint events A1, A2, A3, ...

P (A1 ∪A2 ∪A3 ∪ ...) = P (A1) + P (A2) + P (A3) + ...

P (Ω) = 1

P (A) = 1− P (A)

P (A ∪B) = P (A) + P (B)− P (A ∩B)

5