I'm trying to write an algorithm and I'm rusty on my statistics. Basically my question comes down to how do you get the probability of A given B and C. I'm trying to walk myself through a made up example: If having brown hair gives you a 60% chance of being male, and being 6' tall gives you a 90% chance of being male, then what's the probably that a 6' tall brown haired person is a boy?

Initially, I was thinking that you would do: 1-(1-.6)*(1-0.9) to get the probability of not being male. But after looking at it for 3 seconds I am realizing that that isn't correct. I've been thinking about this for a while and I'm still baffled.

I apologize, I'm sure this question has been answered 50 times already, but I don't know the vocabulary to search and find the right answer. Thanks.

  • 1
    $\begingroup$ It is baffling because you can't get an answer with the information given. Consistent with your stipulations, it's possible that all brown-haired six-footers are female--and it's also possible all of them are male. You might find the closely related question at stats.stackexchange.com/questions/47671 to be helpful. $\endgroup$
    – whuber
    Jul 25, 2019 at 12:35
  • $\begingroup$ It is a case of conditional probability. You may go through this link below, will help in your problem. stat.yale.edu/Courses/1997-98/101/condprob.htm $\endgroup$ Jul 25, 2019 at 12:46

1 Answer 1


So after a lot of thought, and filling up three sheets of paper with venn diagrams, I think I finally figured it out. Whuber's comment is correct; there's not enough information to solve the problem. You also need to have the probability of someone being a boy, the probability of someone having brown hair, and the probability of being 6' tall. For my example, I assume that the probability you have brown hair is 50% and the probability you are 6' tall is 50%.

First it helped to take one variable at a time and draw a venn diagram outlining all the probabilities. If you imagine throwing a dart, then 50% of the time you are going to get a male, with 50% being not male. 50% of the time you will get 6', and there is 90% overlap between male and 6'. So if you multiply 0.5 (probability of being male) by 0.9 (probability that you are male given that you are 6' tall) then you get 0.45. I hope that makes sense. Also, notice that they all add up to 1, that's important. And if you add up all the values inside a circle, and divide by all the values inside and outside a circle, then you get the probability for that circle, etc.

venn diagram

Then it's the same concept but you just add another circle and cut up the pie.

second venn diagram showing another variable

So now we have a 60% overlap between male and brown hair. We basically take each portion of the male circle, and overlay the brown hair circle by 60%. So what our male not 6'portion that used to be 0.05 is split into two portions with 60% of .05 = 0.03 becoming the male and (not 6') and brown hair portion. You can fill in all the values by doing this trick and just remembering that everything needs to add up to one, and that all the values inside each circle need to add up to 0.5 (the probability of that event).

So to get the probability of a boy given that they are 6' and have brown hair, we would do 0.27 /(0.27+0.02), which is the area of the combination of boy, brown, and 6' divided by the total area of brown and 6'.

After thinking tinkering with this for a while, I was able to put it into an algorithm to predict the probability of something happening.

probability_of_event_of_interest = 0.5 #being male
current_probability = probability_of_event_of_interest

p_given_x = 0.9 #probability of being male given that person is 6' tall
intersection = current_probability * p_given_x
current_probability = intersection / ((1-current_probability)*(1-p_given_x) + intersection)
>>> current_probability of being male is 0.9 as we'd expect.

p_given_x = 0.6 #probability of being male given that person has brown hair
intersection = current_probability * p_given_x
current_probability = intersection / ((1-current_probability)*(1-p_given_x) + intersection)
>>> current_probability of being male, given that we have brown hair and 6' tall is 0.931

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.