0
$\begingroup$

I am presented with this problem:

The probability of a program having a bug and crashing is 0.2. There are two testing procedures that can be used to detect bugs. Each testing procedure utilizes 50% of the code and the first one detects 50% of all bugs occurring in its code area. The second testing procedure can detect 30% of the bugs occurring in its code area. Both procedures overlap in their evaluation on 50% of the code that they use during an evaluation and can therefore both detect the same bugs if they occur in this area (but do so in different, independent ways). Neither one of the tests will erroneously produce a bug warning and it is assumed that a major bug is equally likely in all code areas (none of these assumptions is assumed to be realistic for real software testing). How high is the probability that a program does not have a major bug if it passes both testing procedures?

From what I understand, I am trying to find out the following probability and have the following knowledge.

$$ P(C)=0.2\\P(T_{1_{pass}})=0.5*0.5=0.25\\P(T_{2_{pass}})=0.5*0.3=0.15\\ P(\lnot C\mid T_{1_{pass}}\land T_{2_{pass}})=\frac{P(T_{1_{pass}}\land T_{2_{pass}}\mid \lnot C)P(\lnot C)}{P(T_{1_{pass}}\land T_{2_{pass}})}\\ $$

Am I on the right track and understanding the problem statement correctly?

1 Answers 1

0

Let's try to evaluate $P(T_1\wedge T_2| C)$ This is the probability that it passes both tests given that there is a bug. This is complicated somewhat by the fact that the bug may be in the region that both $T_1$ and $T_2$ have access to.

$T_1$ and $T_2$ each cover half of the program, and they overlap on $50\%$ of the code that they cover. This means that $T_1\cap T_2$ is half of the size of $T_1,$ so it is $1/4$ of the code. Thus $T_1\cup T_2$ is $3/4$ of the code, $1/4$ belonging to $T_1$ alone, $1/4$ belonging to $T_2$ alone, and $1/4$ shared.

So if there is a bug present, it has a $1/4$ chance of being in each region. If it's in the region only covered by $T_1,$ it has a $50\%$ chance of going undetected, and similarly $70\%$ for the region covered only by $T_2.$ If it is in the common region, it will only fail to be detected if both $T_1$ and $T_2$ miss, so the probability is $50\%*70\% = 35\%.$ If the bug is in the region not covered by any test, there is an $100\%$ chance of it going undetected. Thus the probability of a bug going undetected given that one was there is $$P(T_1\wedge T_2| C) = \frac{1}{4}(50\% + 70\% + 35\% + 100\%) = 63.75\% $$

The probability $P(T_1\wedge T_2 | \lnot C)$ is much easier to compute. It is $1$ since both tests are assumed to surely pass if there are no bugs.

Thus by Bayes $$ P(\lnot C|T_1\wedge T_2) = \frac{P(T_1\wedge T_2 |\lnot C)P(\lnot C)}{P(T_1\wedge T_2 | \lnot C)P(\lnot C)+ P(T_1\wedge T_2 | C)P(C)} = \frac{1*0.8}{1*0.8+0.6375*0.2} = 86.25\%$$