0
$\begingroup$

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.

Assumptions I have made:

  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?

$\endgroup$
2
  • $\begingroup$ 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. $\endgroup$
    – user126540
    Jul 3, 2015 at 1:25
  • $\begingroup$ @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) $\endgroup$
    – rtindru
    Jul 3, 2015 at 5:27

2 Answers 2

2
$\begingroup$

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} $$

$\endgroup$
1
  • $\begingroup$ Thank you, that's a nice simplification! :D $\endgroup$
    – rtindru
    Jul 6, 2015 at 16:57
1
$\begingroup$

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

and normalize that quantity, and you will have your answer

$\endgroup$
4
  • $\begingroup$ You could still assume the distributions are independent and you should not run into any mathematical inconsistencies. $\endgroup$
    – Andrea
    Jul 3, 2015 at 7:26
  • $\begingroup$ You have to be careful about what is independent. Assuming total independence is pretty useless, assuming marginal indepence of (sex And smilingStatus) doesn't simplify anything. Finally assuming conditional indepence of (sex and smilingStatus | beerStatus) does work but the math is slightly harder (and he shouldn't do that) $\endgroup$ Jul 3, 2015 at 9:14
  • $\begingroup$ @GuillaumeDehaene I have added the extra detail, can you show me where exactly I went wrong so that I can correct this & understand better? $\endgroup$
    – rtindru
    Jul 3, 2015 at 10:27
  • 1
    $\begingroup$ 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) $\endgroup$ Jul 3, 2015 at 14:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .