probability question, P(A|B) The conditional probability that the unit has at most three rooms, given that it has at least two rooms

119 Views Asked by At

I'm having issues with the following problem,

Here is my dataset.

Rooms No._of_units
_____ ____________
1     363
2     2427
3     12474
4     27346
5     31245
6     28606
7     15080
8+    21588

Here is the question The conditional probability that the unit has at most three rooms, given that it has at least two rooms, is: __

Here is what I've tried

sample = {
    1:  363,
    2:  2427,
    3:  12474,
    4:  27346,
    5:  31245,
    6:  28606,
    7:  15080,
    8:  21588
}

n = sum(sample.values())

P_1 = sample[1]/n
P_2 = sample[2]/n
P_3 = sample[3]/n
P_4 = sample[4]/n
P_5 = sample[5]/n
P_6 = sample[6]/n
P_7 = sample[7]/n
P_8 = sample[8]/n

# Probability B is P(1) + P(2) + P(3)
P_B = P_1 + P_2 + P_3

# Probability A is 1 - P(1)
P_A = 1 - P_1

# P(B & A) / P(A)
print(f"{P_B / P_A: .3f}")

The solution I get which is wrong is $0.110$ 'rounded to 3 decimals.

I don't need a solution in python. I'm just using it because I don't know R very well.

Thanks in advance for any help.

2

There are 2 best solutions below

2
On BEST ANSWER

OK, so you know the unit has at least 2 rooms ... how many units are there total that have at least 2 rooms? And out of those, how many have at most 3 rooms, i.e. either exactly 2 or exactly 3 rooms?

... in other words, you should not include the units with exactly 1 room.

So there is your mistake: You divide $P(B)$ (which includes $P_1$) by $P(A)$, but you should divide $P(A\&B) = P_2+P_3$ by $P(A)$

0
On

Let N be the total rooms in the unit. Because of the condition that the unit has at least two rooms, the sample space is reduced to $N-363$,
and favorable cases in the reduced sample space are $2427+12474$ for $2,3$ rooms

Proceed