Bob goes to a party, wearing a hat that fits him well. At the end of the party, Bob picks up a hat, without looking at it. He knows that the hat he has picked is his own with probability p. As a first check to see if he has picked up his own hat, he tries the hat, and if it fits, he decides that it is his own hat.

However, even if the hat picked by Bob is not his own, it is still possible that it fits with probability q. Given that Bob picked a hat that fits him, what is the probability that he is correct in deciding that the hat is indeed his own?

To find the probability that Bob is correct in deciding that the hat he picked is his own, given that it fits him, we can use Bayes' theorem.

Let's denote the event that Bob picked his own hat with A, and the event that the hat he picked fits him with B. We want to find P(A|B), the probability that event A (Bob picked his own hat) occurs given that event B (the hat fits him) has already occurred.

According to Bayes' theorem, we have:
P(A|B) = (P(B|A) * P(A)) / P(B)

Now let's break down the components of this equation:
P(A) is the probability that Bob randomly picked his own hat. Since there are a total of two hats (his own and someone else's), we can assume that this probability is 1/2, or 0.5.

P(B|A) is the probability that the picked hat fits him, given that it is his own hat. As stated in the problem, this probability is given as p.

Lastly, P(B) is the overall probability that the hat he picked fits him. This can be calculated by considering all possible scenarios: Bob picked his own hat and it fits (P(A) * P(B|A)), or Bob picked someone else's hat and it fits. Considering that there are two hats in total and he randomly picks one, the probability of picking someone else's hat is 1/2, and the probability that it fits him is q. Therefore, we can express P(B) as:
P(B) = P(A) * P(B|A) + (1 - P(A)) * P(B|not A)
= 0.5 * p + 0.5 * q

Now, substituting the values back into Bayes' theorem:
P(A|B) = (p * 0.5) / (0.5 * p + 0.5 * q)

Simplifying the expression further:
P(A|B) = p / (p + q)

Therefore, the probability that Bob is correct in deciding that the hat he picked is his own, given that it fits him, is p / (p + q).

To find the probability that Bob is correct in deciding that the hat he picked is his own, given that it fits him, we can use Bayes' theorem.

Let's denote event A as "Bob picked a hat that fits him" and event B as "the hat Bob picked is his own."

We are asked to find the probability of event B (hat is his own) given event A (hat fits him), which is P(B|A). According to Bayes' theorem, this can be calculated as:

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

Now, let's break down the terms:

P(A|B) represents the probability that Bob picks a hat that fits him, given that the hat is his own. Since we know that Bob's own hat fits him, P(A|B) = 1.

P(B) is the prior probability of Bob picking his own hat, without any prior information. Since Bob randomly picks a hat without looking at it, there are n hats at the party, and only one of them is his own. Thus, P(B) = 1/n.

P(A) is the probability that Bob picks a hat that fits him, regardless of whether it is his own or not. This can happen in two ways: either the hat is his own (event B) and he picks it, or the hat is not his own (not B), but it still fits him. So we have:

P(A) = P(A|B) * P(B) + P(A|not B) * P(not B)

Since P(A|B) = 1 and P(A|not B) = q (the probability that a randomly picked hat, which is not Bob's, fits him), and P(not B) = (n-1)/n (the probability that the hat is not his own), we get:

P(A) = 1 * (1/n) + q * ((n - 1)/n)

Finally, substituting these values into Bayes' theorem:

P(B|A) = (1 * (1/n)) / (1 * (1/n) + q * ((n - 1)/n))

Simplifying further:

P(B|A) = 1 / (1 + q * (n - 1))

So, the probability that Bob is correct in deciding that the hat he picked is indeed his own, given that it fits him, is 1 / (1 + q * (n - 1)).