# Random variable and distribution - number of tests a teacher has to make

$100$ students do a test. The probability of failing the test is $0.6$, those that failed, do a retest, the probability of failing the retest is $0.5$. Those that fail the retest do another retest.

What is the distribution of the number of tests the teacher will have to make?

I'm pretty new to this and we barely covered this subject in class so I don't think I know what to do, but this is what I tried:

Set $X=\text{The number of tests made}$.

For $X=100$ the probability is: $0.4^{100}$.

For $X=101$ the probability is: $0.4^{99}+0.6\cdot 0.5$.

For $X=102$ the probability is: $(0.4^{99}+0.3)+(0.4^{98}+0.3^2)$. Either one did two tests or two did one test.

For $X=103$ the probability is: $(0.4^{98}+0.3^2)+(0.4^{97}+0.3^3)$. Either one did one test and another did two, or three did three tests.

From here I can build a function with four cases (for $x=100, 101, x\in[102,200], x\ge200)$ so I don't think I'm on the right path...

EDIT: I see that it won't add up to 1...

In this sort of questions are we supposed to find a function with no cases to represent all the possible probabilities?

The probability of $X=x$ tests needed is the sum over the number of students $n$ who fail the original test of:

• the probability of $100-n$ passes and $n$ fails in the $100$ original test multiplied by
• the probability of $n-1$ passes and $x-100-n$ fails in any order in the first $x-101$ retests multiplied by
• the probability the final retest is a pass

so using the binomial distribution twice, though you need to ensure that all these numbers are non-negative, so the calculation is slightly different when $n=0$, giving as you say $P(X=100)=0.4^{100}$.

That makes the answer $$P(X=x)= \sum_{n=1}^{\min(100,x-100)} {100 \choose n}0.6^n0.4^{100-n} {x-101 \choose n-1} 0.5^{x-100}$$ for $x \ge 101$.

You will find $P(X=101)= 100 \times 0.6^1 \times 0.4^{99}\times 1 \times 0.5^1$ and $P(X=102)= 100 \times 0.6^1 \times 0.4^{99}\times 1 \times 0.5^2+4950 \times 0.6^2 \times 0.4^{98}\times 1 \times 0.5^2$

• Why is there multiplication between 0.6 and 0.4? They're on different branches on the probability tree. Also, why is it the stars and bars formula for the second binomial? – shinzou Apr 26 '15 at 7:49
• Take the example of $n=1$ fail on the initial $100$ tests: $0.6^1$ is the probability of an individual failing and $0.4^{99}$ is the probability of $99$ individuals passing. You want both to happen so you multiply them. You also need to take into account that any $1$ of the first $100$ is the fail so also multiply by ${100 \choose 1}=100$. The second binomial is the probability of $n-1$ passes and $x-100-n$ fails in any order in the first $x-101$ retests multiplied by the probability the final retest is a pass. – Henry Apr 26 '15 at 9:45
• Ok. But why is it the stars and bars or bins and balls? The bins are the amount that passed and the balls are amount that failed the first and second tests? – shinzou Apr 26 '15 at 11:04
• I did not use stars and bars, but they are equivalent to binomial coefficients – Henry Apr 26 '15 at 11:48