1
$\begingroup$

I assume Baye's Theorem is expressed as either:
$P(B|A) = \frac{P(A|B)*P(B)}{P(A)}$
or
$P(A|B) = \frac{P(A) * P(B|A)}{((P(A) * P(B|A)) + (P(A') * P(B|A'))}$

The tutorial problem was:

Assume ten children have the following ages (years) and heights (inches): Heights and ages

I interpreted events A and B as:
P(A): Age x = 9 yr., 4/10
P(B): Height y = 49 in., 3/10
P(B|A): 3/4

The probability of a child being nine years old and exactly forty-nine inches tall is three out of ten. When I use the cumulative probabilities in Baye's Theorem, the result is 0.4 or 0.3999... I have to add one to the number of children 49 inches tall and nine years old to make the result 0.3. When I use the correct probabilities, I get 1. Did I misinterpret the results of the correct formula? Maybe Baye's Theorem is saying that all children 49 inches tall are nine-year-olds. Maybe Baye's Theorem is not the right theorem to use in estimating the probability of getting a nine-year-old who is forty-nine inches tall, $P(A ∩ B)$. I think that is a joint distribution. Is Baye's Theorem referring to a conditional distribution, where I have to assume a "prior" event?

Given $P(A|B) = \frac{P(A)*P(B|A)}{P(B)}$:

# Formula using the wrong probabilities.
print(f'P(A|B) = {((4/10)*(3/10))/(3/10)}')
print(f'P(A|B) = {((4/10)*(3/10))/((4/10)*(3/4)+((6/10)*(0/6)))}')
# Output: 0.4, 0.3999...

# Formula with P(B)+1 to force the known correct answer.
print(f'P(B) + 1, P(A|B) = {((4/10)*(3/4 * 4/10))/ ( (3+1) /10)}')
print(f'P(B|A\') + 1, P(A|B) = {((4/10)*(3/10))/(( (3+1) /10)*(3/4)+((6/10)*(1/6)))}')
# Output: 0.3, 0.3

# Formula for what I thought was the correct interpretation.
print(f'P(A|B) = {((4/10)*(3/4))/(3/10)}')
print(f'P(A|B) = {((4/10)*(3/4))/((4/10)*(3/4)+((6/10)*(0/6)))}')
# Output: 1.000...2, 1
$\endgroup$
5
  • 1
    $\begingroup$ Your formula at the start is incorrect, carefully check where each $A$ and $B$ goes. You seem to confuse conditional ($P(A|B)$ or prob. of A given B is true) an joint probability ($P(A\cap B)$, prob. of A and B both true). Bayes' theorem is used mostly to shuffle around conditional probability and says less about joint, it usually requires the latter to be known up to some integrating constant. Still, you seem to want $P(A|B)$ or the chance of being 9yo given being 49in; how many children of 49in that aren't 9yo are there? $\endgroup$
    – PBulls
    Commented Nov 14, 2023 at 6:31
  • $\begingroup$ @PBulls Which formula is incorrect, the formula in the question text or the Python code? The first two groups of Python code separated by comments are meant to be wrong. I thought the correct code implementation was the last two lines of code that return 1. Also, all children 49 in. tall are nine years old. $\endgroup$ Commented Nov 14, 2023 at 9:01
  • $\begingroup$ Sorry, I mixed up parsing the formula myself - I meant the very first one in your post but it's correct (should teach me not to comment from phone). I still don't follow where the mismatch lies though or what you're trying to do in those bottom calculations; you have $P(A)=0.4$, $P(B)=0.3$, $P(B|A)=0.75$, and $P(A|B)=\frac{P(B|A)P(A)}{P(B)}=\frac{0.75*0.4}{0.3}=1$? Everything in Bayes' theorem holds? $\endgroup$
    – PBulls
    Commented Nov 14, 2023 at 9:24
  • 1
    $\begingroup$ From your picture table $P(A \mid B)=1$ is correct: everybody 49 inches tall is also 9 years old. This is consistent with $P(B \mid A)=\frac34$ since $\frac{P(A)}{P(B)}=\frac43$ $\endgroup$
    – Henry
    Commented Nov 14, 2023 at 11:46
  • $\begingroup$ You're right. Baye's Theorem does hold. I was using it to answer the question of how many children in the entire sample are 49 in. tall and 9 yo. That is a misuse of Baye's Theorem. $\endgroup$ Commented Nov 15, 2023 at 1:07

1 Answer 1

0
$\begingroup$

The first two Python code groups that display either 0.4 or 0.3 are wrong. They do not implement Baye's Theorem. The third group is correct. I was just using Baye's Theorem the wrong way. I wanted to confirm that $P(A∩B) = 0.3$ according to the problem. That is the proportion of the sample children who are nine years old and forty-nine inches tall. Baye's Theorem does not answer that question. It answers the probability of an event given some prior event's probability. For example, it could answer the likelihood or proportion of children who are nine years old ($P(A)$) if/given they are forty-nine inches tall ($P(B)$). This is exactly $P(A|B) = \frac{P(A)∗P(B|A)}{P(B)}$ Refer to the comments of PBulls and Henry:

Comments explaining Baye's use for the problem.

$\endgroup$

Your Answer

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

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