# Baye's Theorem Conditional Probability with multiple conditions

Lets assume I have a supermarket and I track the purchase history of my customers with 2 attributes of each customer - Gender (M/F) & Smiling (Y/N).

Assume this is historical data of purchases:

     |  Total  |  Male  |  Smile
Beer |     25  |    20  |     22

Total articles sold including beer:  40
Total number of customers:           60


I need to find the this conditional probability:

Probability that a given person who is male and is smiling will buy a beer.

I need ---> P(Beer/Male and Smiling)

Bayes Theroem:

P(A|B) = P(B|A) * P(A) / P(B)


Applying this to my problem:

P(B|M,S) = P(M,S|B) * P(B) / P(M,S)
= {P(M|B) * P(S|B)} * P(B) / {P(M) * P(S)}
= (20/25 * 22/25) * 25/40 / (20/60) * (22/60)
= 0.70 * 0.625 / 0.122
= 3.58


I am clearly doing something very, very wrong. Need some guidance.

1. Probability of Male and Smiling is independent - I guess this is where the issue lies
2. P(M,S|B) - This component's calculation & formula - are they right?
3. Is it an issue with the data?

Edit in response to Guillame's answer:

Let me define those for you:

Assuming that Male & Smiling = 15

1. Smiling Males bought beer: 10
2. Smiling Male did not buy beer: 5

Now given this information, where exactly am I going wrong?

• I see that you used $P(M, S \mid B) = P(M\mid B)P(S \mid B)$ which is not necessarily true even if $M$ and $S$ are independent. For the relationship to hold you need conditional independence. I.e. that given they buy beer, the smiling and gender must be independent. You cannot know this from the given the data, however. I believe you need a statistic for $M \cap S \mid B$ in order to calculate the probability you seek.
– user126540
Jul 3, 2015 at 1:25
• @Slungpue Okay so if I know that of the 20 males that bought a beer, 10 were smiling, then can you tell me how this changes equation? Does it make it something like: P(M, S|B) = P(M$intersection$S) Jul 3, 2015 at 5:27

With the information you have now you don't really need Bayes. By the basic definition of conditional probability $$P(B \mid M, S) = \frac{P(M, S, B)}{P(M, S)} = \frac{P(\text{Male, smiling, bought beer})}{P(\text{Male, smiling})} = \frac{10/60}{15/60}= \frac{2}{3}$$

• Thank you, that's a nice simplification! :D Jul 6, 2015 at 16:57

Your current data is insufficient to answer, and this is why you run into errors.

You have a discrete distribution (Beer, noBeer) | (Male, Female) | (Smile, noSmile), so we can think of the joint probability distribution as being a 2*2*2 array (or a Tensor in math-speak)

Right now, the data you are giving specifies only the joint distribution of Beer and sex, and of beer and smile. You need the joint distribution of everything in order to be able to apply bayes formula

So, what you need to look at is:

• how many smiling males bought beer

• how many smiling males didn't buy beer

• With your edit, we now have all the information we need, because you have specified $p(M,S|B)=10/60$ and $p(M,S|\not B)=5/60$. Applying Bayes formula, we get that $p(B|M,S)=2/3$. Note how the total number of individual measured doesn't matters (the total number of people being 60 has no impact. Try it out with 100, and 200 to check) Jul 3, 2015 at 14:32