0
$\begingroup$

I have some software that operates non-deterministically. Running a test on the code can result in a pass or fail depending on unknown external factors. Assuming that the odds of passing or failing are equal because of these factors, how many times must I run the test, and how many times must the software pass the test so that I can say with 95% confidence that the software works as expected 90% of the time?

Edit: Assume that the odds that an external factor causes the test to fail are unknown instead of a pass/fail being equal.

$\endgroup$
5
  • $\begingroup$ So, just to clarify, if the odds of a pass or a fail are the same then this means the probability of succeeding is 50%. Your question boils down to how many times do you have to see a success (or equivalently, a failure) in order to say that the software has a 50% probability of success (failure)? $\endgroup$ Commented Oct 11 at 22:45
  • $\begingroup$ There is something amiss in the question. If the odds of passing or failing are equal, that means the software will fail 50% of the time; does that sound like working? You can not fix the odds as you did. Moreover, you need to specify how often you would like it to work; say 90% of the time? So you want to be 95% confident that your software will pass e.g. 90% of the times it runs? Can you clarify the question a bit? In any case, it ends up being a binomial proportion; e.g. for 95%/90%. 29 pass w/o any failure, or 37 passes out of 38 (1 failure), etc... $\endgroup$
    – jginestet
    Commented Oct 11 at 23:02
  • $\begingroup$ Rather than assuming the odds of a pass or fail are equal due to unknowns, let's assume that the odds that an external factor causes the test to fail are unknown. I.e. we don't know when some fluke causes a test failure. Yes, for the example's sake let's say I want to be 95% confident the software will pass the test 90% of the time. How do I calculate this? $\endgroup$
    – dev01
    Commented Oct 12 at 0:02
  • $\begingroup$ Do you know what the pass rate should be a priori, or is that something you need to also determine? $\endgroup$ Commented Oct 12 at 15:33
  • $\begingroup$ I don't know what the pass rate should be. Maybe we can make a reasonable assumption if it's required? $\endgroup$
    – dev01
    Commented Oct 12 at 17:02

1 Answer 1

1
$\begingroup$

You need to determine a margin of error. The margin of error tells you, roughly, the likely amount of sampling error from a sample of observations.

Since your outcome is binary the margin of error is, roughly $^1$,

$$ MOE \approx \dfrac{1}{\sqrt{N}} $$

So if you pick a margin of error, you can solve for $N$, leading to

$$ N \approx \dfrac{1}{MOE^2} $$

Here is a hypothetical example. Say I want to know the success rate of the machine to within 1% (equivalently, 0.01). My margin of error is then 0.01, and using this formula I would need 10, 000 samples since

$$ N = \dfrac{1}{0.01^2} = 10,000 $$

I could then claim I have estimated the success rate of the machine (assuming I did a simple random sample, etc etc) to within a margin of error of 0.01, meaning -- again, roughly -- the the true success rate could be my estimate plus or minus 1%.

We can not tell you what your margin of error should be. This depends on your constraints and context. That being said, this should tell you how many samples you need as a function of how certain you need your estimate to be.


Footnotes

  1. The actual margin of error for a binomial random variable is

$$ z_{1-\alpha/2} \times \sqrt{\dfrac{p(1-p)}{N}} $$

and is equal to the radius of the Wald confidence interval for the binomial parameter. Using the typical 95% confidence interval, $z_{1-\alpha/2} \approx 2$. Since $p$ is unknown, and the margin of error is maximized when $p=0.5$, we can actually create an upper bound for the margin of error

$$ MOE = z_{1-\alpha/2} \times \sqrt{\dfrac{p(1-p)}{N}} \leq 2 \sqrt{\dfrac{0.5^2}{N}} \>.$$

Hence, $N \leq \dfrac{1}{MOE^2}$ is likely an over estimation of the number fof required samples, but will guarantee a margin of error of at most $MOE$.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.