Computing Posterior Probabilities CSE 4308/5360: Artificial Intelligence I University of Texas at Arlington 1
Overview of Candy Bag Example As described in Russell and Norvig, for Chapter 20 of the 2 nd edition: • Five kinds of bags of candies. – 10% are h 1 : 100% cherry candies – 20% are h 2 : 75% cherry candies + 25% lime candies – 40% are h 3 : 50% cherry candies + 50% lime candies – 20% are h 4 : 25% cherry candies + 75% lime candies – 10% are h 5 : 100% lime candies • Each bag has an infinite number of candies. – This way, the ratio of candy types inside a bag does not change as we pick candies out of the bag. • We have a bag, and we are picking candies out of it. • Based on the types of candies we are picking, we want to figure out what type of bag we have. 2
Hypotheses and Prior Probabilities • Five kinds of bags of candies. – 10% are h 1 : 100% cherry candies – 20% are h 2 : 75% cherry candies + 25% lime candies – 40% are h 3 : 50% cherry candies + 50% lime candies – 20% are h 4 : 25% cherry candies + 75% lime candies – 10% are h 5 : 100% lime candies • Each h i is called a hypothesis . • The initial probability that is given for each hypothesis is called the prior probability for that hypothesis. – It is called prior because it is the probability we have before we have made any observations. 3
Observations and Posteriors • Out of our bag, we pick T candies, whose types are: Q 1 , Q 2 , …, Q T . – Each Q j is equal to either C (cherry) or L (“lime”). – These Q j ’s are called the observations . • Based on our observations, we want to answer two types of questions: • What is P(h i | Q 1 , …, Q t )? – Probability of hypothesis i after t observations. – This is called the posterior probability of h i . • What is P(Q t+1 = C | Q 1 , …, Q t )? – Similarly, what is P(Q t+1 = L | Q 1 , …, Q t ) 4 – Probability of observation t+1 after t observations.
Simplifying notation • Define: – P t (h i ) = P(h i | Q 1 , …, Q t ) – P t (Q t+1 = C) = P(Q t+1 = C | Q 1 , …, Q t )? • Special case: t = 0 (no observations): – P 0 (h i ) = P(h i ) • P 0 (h i ) is the prior probability of h i – P 0 (Q 1 = C) = P(Q 1 = C) • P 0 (Q 1 = C) is the probability that the first observation is equal to C. 5
Questions We Want to Answer, Revisited Using the simplified notation of the previous slide: • What is P t (h i )? – Posterior probability of hypothesis i after t observations. • What is P t (Q t+1 = C)? – Similarly, what is P t (Q t+1 = L) – Probability of observation t+1 after t observations. 6
A Special Case of Bayes Rule • In the solution, we will use the following special case of Bayes rule: – P(A | B, C) = P(B | A, C) * P(A | C) / P(B | C). 7
Computing P t (h i ) • Let t be an integer between 1 and T: • P t (h i ) = P(h i | Q1, …, Q t ) = P(Q t | h i , Q 1 , …, Q t-1 ) * P(h i | Q 1 , …, Q t-1 ) => P(Q t | Q 1 , …, Q t-1 ) P(Q t | h i ) * P t-1 (h i ) => P t (h i ) = P t-1 (Q t ) 8
Computing P t (h i ) (continued) P(Q t | h i ) * P t-1 (h i ) P t (h i ) = • The formula P t-1 (Q t ) is recursive, as it requires knowing P t-1 (h i ). • The base case is P 0 (h i ) = P(h i ). • To compute P t (h i ) we also need P t-1 (Q t ). We show how to compute that next. 9
Computing P t+1 (Q t ) • P t (Q t+1 ) = P(Q t+1 | Q 1 , …, Q t ) = 5 Σ (P(Q t+1 | h i ) P(h i | Q 1 , …, Q t )) => i=1 5 Σ P t (Q t+1 ) = (P(Q t+1 | h i ) P t (h i )) i=1 10
Computing P t (h i ) and P t (Q t+1 ) • Base case: t = 0. – P 0 (h i ) = P(h i ), where P(h i ) is known. 5 Σ – P 0 (Q 1 ) = ( P(Q 1 | h i ) * P(h i ) ), where P(Q 1 | h i ) is known. i=1 • To compute P t (h i ) and P t (Q t+1 ): • For j = 1, …, t P(Q j | h i ) * P j-1 (h i ) P j (h i ) = – Compute P j-1 (Q j ) 5 Σ – Compute P j (Q j+1 ) = ( P(Q j+1 | h i ) * P j (h i )) 11 i=1
Computing P t (h i ) and P t (Q t+1 ) • Base case: t = 0. – P 0 (h i ) = P(h i ), where P(h i ) is known. 5 Σ – P 0 (Q 1 ) = ( P(Q 1 | h i ) * P(h i ) ), where P(Q 1 | h i ) is known. i=1 • To compute P t (h i ) and P t (Q t+1 ): • For j = 1, …, t known computed at previous round P(Q j | h i ) * P j-1 (h i ) P j (h i ) = – Compute P j-1 (Q j ) computed at previous round 5 Σ – Compute P j (Q j+1 ) = ( P(Q j+1 | h i ) * P j (h i )) 12 i=1 computed at previous line known
Recommend
More recommend