Comments on: What should my sample size be?
http://ask.metafilter.com/228707/What-should-my-sample-size-be/
Comments on Ask MetaFilter post What should my sample size be?Mon, 12 Nov 2012 08:36:03 -0800Mon, 12 Nov 2012 08:44:52 -0800en-ushttp://blogs.law.harvard.edu/tech/rss60Question: What should my sample size be?
http://ask.metafilter.com/228707/What-should-my-sample-size-be
Say that I have a bag which contains 100 balls and every ball in the bag should be red, but it's possible that one or more of these balls is the wrong colour. How many balls should I look at to be 90% sure that all the balls are red? Or 95%? Or 99.9%? Talk me through how to work this out, please?post:ask.metafilter.com,2012:site.228707Mon, 12 Nov 2012 08:36:03 -0800xchmpstatisticsmathsmathBy: cr_joe
http://ask.metafilter.com/228707/What-should-my-sample-size-be#3309577
Can you take the balls out and leave them out, or do you only get to look at one ball at a time? In other words, do you have to replace every ball you examine?comment:ask.metafilter.com,2012:site.228707-3309577Mon, 12 Nov 2012 08:44:52 -0800cr_joeBy: Tanizaki
http://ask.metafilter.com/228707/What-should-my-sample-size-be#3309584
I usually thing of "percent certainty" in terms of confidence interval for experimental results. However, if you reach into the bag and pull out a green ball on your first effort, you can know with 100% certainty that not all of the balls are red.<br>
<br>
Assuming that you want to know how many red balls you would have to pull out to have 90% certainty that all balls are red, pull out 90 balls. However, this is just another way of saying that you know with certainty that 90% of the balls are red.<br>
<br>
99.5% does not make sense for such a small sample size.comment:ask.metafilter.com,2012:site.228707-3309584Mon, 12 Nov 2012 08:46:10 -0800TanizakiBy: xchmp
http://ask.metafilter.com/228707/What-should-my-sample-size-be#3309585
Once I've taken a ball out the bag it stays out. So I guess the question is how many I need to take out.comment:ask.metafilter.com,2012:site.228707-3309585Mon, 12 Nov 2012 08:46:27 -0800xchmpBy: clockzero
http://ask.metafilter.com/228707/What-should-my-sample-size-be#3309617
What would it mean to be 90% sure that all the balls are red? Does that mean that there's a 9/10 chance that any given ball is red? Because those seem like slightly different things, but it's hard for me to tell what you're looking for.comment:ask.metafilter.com,2012:site.228707-3309617Mon, 12 Nov 2012 09:12:01 -0800clockzeroBy: madcaptenor
http://ask.metafilter.com/228707/What-should-my-sample-size-be#3309620
You need to specify the problem more completely. Before you draw any balls out of the box, what do you believe is the probability that there are black balls? If there are black balls, how many are there? For example, you could say that the probability of no black balls is 80%, the probability of one black ball is 15%, and the probability of two black balls is 5%.<br>
<br>
Then you use Bayes' theorem to figure out how you should update that as you draw balls and see their color. Doubtless someone reading this can help out. (I could, but I probably won't because I'm on my way to work.)comment:ask.metafilter.com,2012:site.228707-3309620Mon, 12 Nov 2012 09:17:59 -0800madcaptenorBy: Ruthless Bunny
http://ask.metafilter.com/228707/What-should-my-sample-size-be#3309624
I was reminded of <a href="http://en.wikipedia.org/wiki/Erlang_distribution">Erlang Tables</a>, which we used at the phone company to determine how many phone lines a business would need to handle X% of traffic at the busiest time.<br>
<br>
This also works for how many restrooms do you need in a stadium to achieve a certian rate of service (how many angry women are in a line waiting for a stall and for how long) <br>
<br>
But I'm reminiscing. <br>
<br>
I found a <a href="http://www.surveysystem.com/sscalc.htm">Sample Size Calculator</a>, and you'd need to know your Confidence Level (95% or 90% confident) and the interval, the number you're comfortable being off by, plus or minus. So for example, if you're okay with being off by 5 balls, and you want 95% confidence, then the answer is: 80 Balls. <br>
<br>
Fool around with the calculator, and there's some interesting stuff about statistical samples on the site.comment:ask.metafilter.com,2012:site.228707-3309624Mon, 12 Nov 2012 09:21:15 -0800Ruthless BunnyBy: CustooFintel
http://ask.metafilter.com/228707/What-should-my-sample-size-be#3309635
To answer this question, we need some sort of baseline idea for the chance of each individual ball being red. If the color of each ball is understood to be random, then the chance of a ball being red would seem to be rather small; if the balls were, as you implied, intended to be red all along, and would only be a different color due to some mistake, then the chance of any individual ball being red would seem to be very high; and everything inbetween.<br>
<br>
So the bag contains N balls. Suppose the chance of any individual ball being red is P. The chance of all N balls being red is N multiplied by P. The chance of all N balls being red, having already removed X balls and confirmed them to be red, is N - X * P (assuming that N > X).<br>
<br>
So: if the chance of any individual ball being red is 50%, then without removing any balls, the chance of all 100 being red is 50% times 2^100, which is an absurdly minute fraction. If we remove 90 balls, all of which turn out to be red, then the chance of every single ball being red is 50% times 2^10 - the same as if the bag only contained 10 balls to begin with, and we removed none of them. If we remove 99 balls, all of them red, then the chance that every single ball is red is the same as the chance that the very last ball is red: 50%.<br>
<br>
The number of balls you rermove from the bag and confirm to be red is, in a sense, irrelevant - what matters is how many balls remain in the bag.<br>
<br>
If you wish to be 99% certain that every ball is red, then the chance that each individual ball is red must be at least 99%. If, for instance, you want to be this certain when their are two balls remaining, then the probability of each individual ball being red must be the square root of 99%, or rather, the square root of .99, which my calculator informs me is .994987.comment:ask.metafilter.com,2012:site.228707-3309635Mon, 12 Nov 2012 09:23:36 -0800CustooFintelBy: cr_joe
http://ask.metafilter.com/228707/What-should-my-sample-size-be#3309666
The "or more" part is what's throwing me off. Though there's much more sophisticated answers here, I'm thinking about it in terms of percentages of probability of "fewer than X number of black balls." <br>
<br>
For instance, if I remove 30 balls (and they're all red) I know that there's:<br>
100% chance that there are fewer than 70 black balls (70/(100-30))<br>
86% chance of being fewer than 60 (60/(100-30)<br>
71% chance of being fewer than 50<br>
57% chance of being fewer than 40<br>
43% chance of being fewer than 30<br>
29% chance of being fewer than 20<br>
14% chance of being fewer than 10<br>
1.4% chance of being fewer than 1comment:ask.metafilter.com,2012:site.228707-3309666Mon, 12 Nov 2012 09:39:48 -0800cr_joeBy: zeptoweasel
http://ask.metafilter.com/228707/What-should-my-sample-size-be#3309674
<em>Assuming that you want to know how many red balls you would have to pull out to have 90% certainty that all balls are red, pull out 90 balls.</em><br>
<br>
Exactly. On a related note, you may be interested in the odds that there are fewer than <em>k</em> non-red balls in the bag. So, we can compute the probability of drawing <em>n</em> red balls in a row if there are <em>k</em> non-red balls:<br>
<br>
p = (100-k)/100 * (99-k)/99 * ... * (101-n-k)/(101-n)<br>
<br>
since at step <em>j</em>, either you draw one of the 101<em>-j-k</em> red balls remaining out of the 101-<em>j</em> balls in the bag, or you stop the process. Once <em>p</em> drops below 0.05, you're 95% confident that there are fewer than <em>k</em> non-red balls in the bag. If <em>k</em>=1, this calculation turns into the telescoping product<br>
<br>
p = 99/100 * 98/99 * ... * (100-n)/(101-n) = (100-n)/100,<br>
<br>
which means that to be 90% confident there are no (i.e. fewer than 1) non-red balls in the bag, you should pull out 90 balls.<br>
<br>
This also means that once you've pulled out the 90 balls, it's 99% safe to say there are fewer than 2 non-red, 99.9% safe to say there are fewer than 3, and mathematically certain that there are fewer than 11.comment:ask.metafilter.com,2012:site.228707-3309674Mon, 12 Nov 2012 09:43:18 -0800zeptoweaselBy: phearlez
http://ask.metafilter.com/228707/What-should-my-sample-size-be#3309710
Will we be getting co-credit on your homework?<br>
<br>
Madcaptenor is right, this is insufficient information to determine what you need. When you're all done sampling do the balls go back in the bag? Or is the test destructive in this regards? If so, do you have a target number you need to have when your tests are finished or will any size remaining sample do? Which can't be exactly true or else you'd simply test every one.<br>
<br>
You should focus your research on manufacturing or purchase-acceptance testing; the red/black thing is a macguffin: you're looking to determine, absent any knowledge of a failure rate, what your bare minimum number of necessary tests are to determine if something is good.<br>
<br>
I'm assuming you're still in that IT degree, in which case the principle here is likely <em>operating characteristics</em>.<br>
<br>
<a href="http://wps.prenhall.com/wps/media/objects/9434/9660836/online_tutorials/heizer10e_tut2.pdf">Here's a P-H text which addressed this directly and has the appropriate formulas</a>.<br>
<br>
<blockquote><br>
To help you understand the theory underlying the use of sampling plans, we will illustrate how an OC curve is constructed statistically.<br>
<br>
In attribute sampling, where products are determined to be either good or bad, a binomial distribution is usually employed to build the OC curve. The binomial equation is (T2-1)<br>
<br>
where n = number of items sampled (called trials)<br>
p = probability that an x (defect) will occur on any one trial<br>
P(x) = probability of exactly x results in n trials<br>
<br>
When the sample size (n) is large and the percent defective (p) is small, however, the Poisson distribution can be used as an approximation of the binomial formula. This is convenient because binomial calculations can become quite complex, and because cumulative Poisson tables are readily available. Our Poisson table appears in Appendix II of the text.<br>
<br>
In a Poisson approximation of the binomial distribution, the mean of the binomial, which is np, is used as the mean of the Poisson, which is λ; that is, λ = np<br>
</blockquote><br>
<br>
By the way, <a href="http://xkcd.com/1132/">XKCD was somewhat on-point for you the other day.</a>comment:ask.metafilter.com,2012:site.228707-3309710Mon, 12 Nov 2012 09:57:20 -0800phearlezBy: xchmp
http://ask.metafilter.com/228707/What-should-my-sample-size-be#3309716
<i>Madcaptenor is right, this is insufficient information to determine what you need. When you're all done sampling do the balls go back in the bag? Or is the test destructive in this regards? If so, do you have a target number you need to have when your tests are finished or will any size remaining sample do? Which can't be exactly true or else you'd simply test every one.</i><br>
<br>
I think my hypothetical is just getting in the way here.<br>
<br>
So the real situation involves software rather that balls. The software will select a certain number of things according to specific criteria. I'm trying to work out how many of these I should manually check to give (some level) of confidence that no 'wrong' things have been selected.<br>
<br>
The number of items in the 'bag' will vary between the hundreds to the tens of thousands, so checking every one of them isn't an option. I want to be able to say that checking x number of the y items will give us z level of confidence in the software process.comment:ask.metafilter.com,2012:site.228707-3309716Mon, 12 Nov 2012 10:09:20 -0800xchmpBy: xchmp
http://ask.metafilter.com/228707/What-should-my-sample-size-be#3309720
That Acceptance Sampling paper looks great, by the way. I'll read that now.comment:ask.metafilter.com,2012:site.228707-3309720Mon, 12 Nov 2012 10:12:52 -0800xchmpBy: siskin
http://ask.metafilter.com/228707/What-should-my-sample-size-be#3309732
I found an excellent discussion of a very similar question via the Xkcd comic linked above - <a href="http://www.quora.com/Mathematics/I-have-burned-200-disks-and-I-want-to-make-sure-that-they-are-all-in-perfect-working-order-What-is-the-smallest-size-sample-I-could-test-in-order-to-be-relatively-confident-that-98-of-all-the-disks-are-fine-burned-correctly/answers/895223?srid=tL&st=ns#">I have burned 200 disks and I want to make sure that they are all in perfect working order. What is the smallest size sample I could test in order to be relatively confident that 98% of all the disks are fine/burned correctly?</a> (it's on Quora - you don't need to log in to see it).comment:ask.metafilter.com,2012:site.228707-3309732Mon, 12 Nov 2012 10:24:55 -0800siskinBy: xchmp
http://ask.metafilter.com/228707/What-should-my-sample-size-be#3311173
Thanks everyone. It turns out that acceptance sampling is exactly what I was looking for. I don't know the defect rate, but I can use acceptance sampling to work out the probability that the number of defects is below various thresholds and make decisions about sample size on that basis. <br>
<br>
<i>Will we be getting co-credit on your homework?</i><br>
<br>
This was actual work rather than homework. I'll consider linking to your answer in my test plan, though.comment:ask.metafilter.com,2012:site.228707-3311173Tue, 13 Nov 2012 09:22:23 -0800xchmp