# Are the balls drawn randomly (independently of the number of balls existing in their colours)?

We have a big urn that contain $N_{Tot}$ balls. Balls are of $r$ different colours. The number of balls of the $i^{th}$ colour (before sampling) is $N_i$. John sampled $x$ balls in total (without replacement) from this urn. The number of balls of each colour are $x_1, x_2, ..., x_{r-1}, x_r$.

The question I am trying to answer: Did John sample balls independently of the number of balls existing in it's colour?

My thoughts

I first thought a simple regression with $r$ data points, where the x variable is the number of balls in this color and the y coordinate is the number of balls that were sampled in this color. But that wouldn't work. One obvious reason is that each point is not an independent observation as sampling the first ball from one colour means not sampling the first ball in another colour.

$x_i$ should follow a hypergeometric distribution with parameters $N_{tot}-N_i$ (failure), $N_i$ (success) and $x$ (total number of balls drawn), where $N_{tot} = \sum_{i=1}^r N_i$ is the total number of balls. I can compare $x_i$ to the median of the hypergeometric distribution to tell for each colour whether the urn was rather overrepresented in the sample or underrepresented. Let's call this binary variable $B$

Then, I can perform a Spearman correlation between $B$ and the number of balls in each colour $N_1, N_2, ..., N_{r-1}, N_r$. If the p.value of the Spearman correlation is low enough then, I can conclude that the balls were not drawn at random independently of the colour of the balls.

Does it seem to be a good methodology?

Would it be a test with low power or would it be completely wrong?

• +1 This is an example of the multivariate hypergeometric distribution. – whuber Jun 15 '15 at 22:21
• Thnks that seems interesting. I don't quite get how I can ask whether the number of balls in the colour changes the probability of sampling one given ball of that color (Ha) or not (Ho). – Sulawesi Jun 15 '15 at 23:12
• I would love to give a bounty to attract more attention but I am afraid I don't have enough reputation for that! – Sulawesi Jun 19 '15 at 17:47
• Is there some reason why you can't use a Chi-square test for this? It seems that you can calculate the expected number of each color of ball collected, based on the multivariate hypergeometric distribution. Then a standard Chi-square test based on observed numbers of each color would indicate whether the sample was significantly far from what would have been expected. – EdM Jun 19 '15 at 19:01
• @EdM Sorry, I missed your comment for some reason. You'd make a Chi-square test comparing the observed value and the expected (which is the mean of the hypergeometric distribution for this color), is that right (summed over all colors)? Isn't it an issue that the observed values aren't independent? – Sulawesi Jun 24 '15 at 17:41