How to solve this question of picking balls from bins, question is probability of ball number vs selection number? I'm a student and always get confused with different combinations of balls in bins problem. I've encountered this question today and not able to solve this. Hope someone can give me some pointers, thanks! If there are any related materials I need to refresh, that would be helpful as well.
You have been given 3 balls which are numbered as 1, 2 and 3 and they are placed inside a bag. You randomly select 3 balls, one ball at a time. Considering your selection, you win if at least one selection number matches with the number on the ball. So for example if you get ball with number 1 on your first draw you call this as win. The question is what are the chances of winning if you do this with replacement versus without replacement.
 A: a) With replacement -
The probability of drawing a specific ball out of three balls $= \frac{1}{3}$
What is the probability that in the first draw you fetched the ball number $2$ or $3 = \frac{2}{3}$
Similarly in the second draw probability that you fetched ball number $1$ or $3 = \frac{2}{3}$
Similarly in the third draw probability that you fetched ball number $1$ or $2 = \frac{2}{3}$
So the probability that you did not fetch any ball correctly in three draws $= \frac{2}{3} \times \frac{2}{3} \times \frac{2}{3} = \frac{8}{27}$
Subtracting this from $1$ will give you probability of at least fetching one ball correctly.
b) Without replacement
In this specific case as there are only $3$ balls, you can easily count that there are only two ways in which none of the balls are fetched correctly -
Order of fetch - ball numbers $(2 \, 3 \, 1)$ or $(3 \, 1 \, 2)$. Any other order will have at least one ball fetched correctly.
With bigger numbers, Without Replacement poses complications as you get into situations where the counting will have duplicates so you need to apply the principle of inclusion exclusion which leads to derangement formula. Have you heard of derangement problems like if hats are collected from a group of people, mixed and randomly distributed among them, what is the probability that nobody gets their own hat? This problem is similar.
Number of ways in which no draw would fetch the right ball number = derangement of $3 = \, !3 = 2$
Number of ways to fetch $3$ balls in different order $= \, ^3C_1 \times \, ^2C_1 \times \, ^1C_1 = 6$
So the probability $= \frac{1}{3}$. Again if you subtract this from $1$, you get the probability of at least one correct fetch.
A: I like to simulate such problems as a double check on the
combinatorial logic. [@MathLover's Answer (+1), which you might consider Accepting, and @JMoravitz' Comment have
put you on the right track.]
# without replacement
set.seed(2020)
win.wo = replicate(10^6, sum(sample(1:3, 3)==1:3))
mean(win.wo > 0)
[1] 0.666828       # aprx 1 - (2/3)(1/2) = 2/3

# with replacement
win.wr = replicate(10^6, sum(sample(1:3, 3, rep=T)==1:3))
mean(win.wr > 0)
[1] 0.702987       # aprx 1 = (2/3)^2 = 19/27
1 - dbinom(0, 3, 1/3)
[1] 0.7037037      # Exact binomial computation

Notes: win.w0 and win.wr are vectors of length 1,000,000 with numbers of wins; we want one or more. Logical vector
(win.wr > 0) has a million TRUEs and FALSEs; its mean
is the proportion of its TRUEs. Similarly, for win.wr.
With a million iterations of the game we can expect 2 or 3
place accuracy for the probabilities.
'sample' does the sampling.  Examples:
sample(1:3, 3)
[1] 2 3 1
sample(1:3, 3)
[1] 1 2 3
s = sample(1:3, 3)
[1] 2 1 3
s == 1:3
[1] FALSE FALSE  TRUE
sum(s == 1:3)
[1] 1

sample(1:3, 3, rep=T)
[1] 1 2 2
sample(1:3, 3, rep=T)
[1] 3 3 3
sample(1:3, 3, rep=T)
[1] 2 3 2
sample(1:3, 3, rep=T)
[1] 1 3 2

