patfee
patfee

Reputation: 51

Probability calculations

Cannot get my head around "probability". Assuming:

N <- 5 #balls in a pot
R <- 3 #balls selected from the pot without putting them back
Z <- 2 #correct selected from the pot

A total of ten combinations is possible:

       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
 [1,]    1    1    1    1    1    1    2    2    2     3
 [2,]    2    2    2    3    3    4    3    3    4     4
 [3,]    3    4    5    4    5    5    4    5    5     5

When I assume that Z is both the numbers 1 and 2, we count that this applies for three combinations.

I would think that the probability would be 3 / 10 = 0.3 = 30%

This is different from the result I get from Excel:

=HYPGEOMDIST(2;3;3;5)

It is also different from the result in R:

choose(R,Z)*choose((N-R),(R-Z))/choose(N,R)

Both outcomes equal 0.6 = 60%

What am I missing here please?

Upvotes: 1

Views: 198

Answers (3)

brettdj
brettdj

Reputation: 55692

Or in Excel (in addition to Henrik's answer)

=COMBIN(3,2)/COMBIN(5,3)

=3/10
=30%

Upvotes: 1

BallpointBen
BallpointBen

Reputation: 13820

I think the computation should be:

choose(N-Z,R-Z)/choose(N,R)=choose(5-2,1)/choose(5,3)=0.3

The total is clearly choose(N,R). The number of successes is the number of ways to pick the balls other than the "correct" balls. There are N-Z balls to choose from and you must choose R-Z -- the -Z is in both because you've already chosen the correct balls, so they are taken out of the equation.

Upvotes: 1

Henrik
Henrik

Reputation: 23324

HYPGEOMDIST(2;3;2;5) yields 0.3 as expected.

Upvotes: 1

Related Questions