4

Imagine we have a jar of marbles, where there are 10 different colors of marbles in the jar. Let N be the number of marbles drawn in a sample and K be the number of distinct colors in the sample. Let C be the total number of colors in the jar (which is 10 in this example).

We know that: K = F(C,N) + chance.

Intuitively, the more marbles we draw at a time, the more colors we are likely to obtain, up to the maximum.

This strikes me as a binomial. I am looking for a formula to express in more detail how K = F(C,N). An obvious feature is that C is the maximum value. So I figure this is a model where K is an increasing proportion of C as N increases.

I already know how to simulate the data, but wish to provide an expression of K depending on C and N.

Any suggestions will be appreciated.

Simulated data for the situation I intend will be as follows. I assume sampling with replacement. For this example, we have 10 colors in the jar (C=10). Note that we start by drawing one marble from the jar, which gives us a sample where N=1 and K=1. The number of colors found in a sample depends on the size of the sample. In this case it is seq(1:20). In this particular simulation, we have an equal representation for each color. The snip of R code I use to simulate the data is:

###snip of modified code for stack exchange exchange

T <- c(1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10)

for (i in 1:N){
for (s in 1:n.sims) {
plot.sample <- sample(T, size=N[i])
K[s,i] <- length(unique(plot.sample))
}
}

Plot of K = f(N,C) where C is max(K)

Note that the line is just a loess plot at this point and the proper function would level off at C, the maximum number of colors.

If I use the suggested formula K=N*C/(N+C-1) I get the figure on the right, which has the right shape, but finds colors very slowly. enter image description here

If I estimate the function with a scaling coefficient, I get the following graph. Excellent fit: explained variance = 97%, though the visual suggests there could be a better function?

Fit of K=aNC/(N+C-1)

  • It is not clear from your question if it is assumed that the numbers of marbles of each color are assumed to be equal. – user Dec 25 '20 at 01:00
  • There is no assumption being made about the proportionality of the different colors, so the result will not be fully deterministic, but instead, probabilistic. – Jim Grace Dec 25 '20 at 02:55
  • Why do you use the equal number (2) of marbles of each color in your example? What is known about the number of marbles in the jar? – user Dec 25 '20 at 16:21
  • The number of marbles of each color will vary. The actual work is not marbles, but organisms of different times found in ecological communities. – Jim Grace Dec 25 '20 at 18:35
  • We still need need to know the proportion of the given organisms in the community. The result strongly depends on the value. – user Dec 25 '20 at 20:35
  • In statistical analysis we often do know all the relevant information. This is one of those cases. It means you cannot compute the deterministic solution, but you can fit data to the form of the function. – Jim Grace Dec 25 '20 at 20:55
  • The function depends on the parameters, and these parameters are the proportions mentioned in my comment. Imagine there are two types of organisms and one is 10000000 times more frequent than the other. It certainly affect the number of different types in a sample of 10 organisms. – user Dec 25 '20 at 22:57

3 Answers3

2

I'll assume the jar contains a sufficiently large number of balls equally distributed among the colors. If we don't assume equi-distribution of colors or if we take into account the fact we are drawing without replacement the problem becomes significantly more complicated. Supposing we draw $n$ balls from a jar containing $c$ colors, what is the distribution of the random variable $K$, the number of colors in the sample? (assuming $\boldsymbol{n\geq c}$)

This is a stars-and-bars calculation. Given $c$ different colors possible and our sample being of size $n$, the number of different samples we can get is $$\mathrm{C}(n+c-1,c-1)$$ With $\mathrm{C}$ being of course the binomial coefficient. Of these possible samples, how many of them contain exactly $k$ different colors? Well, we basically don't get to pick the first $k$ balls - they have to be the $k$ distinct colors. But, the remaining $n-k$ balls can be any mixture of the $k$ colors we already have. The number of ways of selecting $n-k$ balls when we have $k$ color choices is $$\mathrm{C}(n-1,k-1)$$ Finally, the number of ways of selecting which $k$ colors out of a pool of $c$ our sample will consist of is precisely $$\mathrm{C}(c,k)$$ Meaning that the number of ways of picking a sample of size $n$ that has exactly $k$ different colors out of a possible $c$ is exactly $$\mathrm{C}(c,k)\mathrm{C}(n-1,k-1)$$ Meaning that $$\Pr(K=k)=\frac{\mathrm{C}(c,k)\mathrm{C}(n-1,k-1)}{\mathrm{C}(n+c-1,c-1)}$$ As a sanity check, it can be verified that $$\sum_{k=1}^c \frac{\mathrm{C}(c,k)\mathrm{C}(n-1,k-1)}{\mathrm{C}(n+c-1,c-1)}=1$$ As long as $n\geq c$. Here is a plot for the $n=50,c=20$ case:

enter image description here

It can also be computed directly that $$\mathrm{E}[K]=\frac{nc}{n+c-1}$$ And $$\operatorname{Var}[K]=\frac{nc(nc-1)}{(n+c-1)(n+c-2)}-\left(\frac{nc}{n+c-1}\right)^2$$

EDIT: Numerical evidence seems to suggest my probability mass function gives correct results even for $n<c$.

K.defaoite
  • 12,536
1

When you talk of asymptotic expressions, you seem to be assuming a large number of draws, where it is likely you have seen all the colors. This simplifies the problem considerably. It also helps if the draws are with replacement or if there are so many marbles that the number you draw does not change the mix appreciably. If there are equal numbers of each type of marble, the chance that a particular type is not drawn is $\left(\frac{C-1}C\right)^N$. When $N$ is large, the chance you have not seen a specific color is small, as you think. The chance you have not seen two different colors is roughly the square of small, which is very small. In that case, the chance you have missed some color is just $C\left(\frac{C-1}C\right)^N$. Is this at all what you were looking for?

Ross Millikan
  • 374,822
  • I was thinking of an expression similar to the Michalis Mention function: K=C*(N/b+N)) where b=the half-saturation constant. The problem with the MM function is that it can predict values greater than C, which is the absolute maximum. A graph for that function can be seen at: https://www.statforbiology.com/nonlinearregression/usefulequations#michaelis-menten_equation – Jim Grace Dec 25 '20 at 03:19
  • That will be badly wrong when the probability gets small, which is exactly what asymptotic calls out. Exponentials get small much faster than that function. If $N=3C$, so you should have seen three of each color, the exponential is about $e^{-3} \approx 0.05$. When $N=5C$ the exponential is about $0.0067$ – Ross Millikan Dec 25 '20 at 03:27
  • Sorry, but I don't understand what you are suggesting. You say you have given a formula for "The chance that a particular type is not drawn." However, what I am looking for is a formula for K, the number of types found in a sample, as a function of N, the number of marbles pulled in the sample. I converted your suggestion into: K = ((C-1)/C)*exp(N) and when N=1, it returns K=2.44 when K must be equal to 1 (one marble pulled will produce 1 color found). – Jim Grace Dec 25 '20 at 04:10
  • The chance that a particular type is not drawn means you choose one color, do your draw, and ask the chance that particular color is missing in the draw. I later multiply by $C$ to get the chance that some one color is missing, having given some justification of that. – Ross Millikan Dec 25 '20 at 04:14
1

Let $m_1,m_2,\dots,m_C$ be the numbers of murbles of the corresponding color, so that $$\sum_{i=1}^C m_i=M, $$ where $M $ is the total number of marbles in the jar (not given in the problem).

Then the probability that a sample of $N $ marbles will contain marbles of $K $ distinct colors is: $$p_K(N,m_1,m_2,\dots,m_C)=\frac {[x^N]:\sum_{\mathbf a}^{ |\mathbf a|=K}\prod_{i=1}^C[(1+x)^{a_im_i}-a_i]}{\binom MN}, $$ where the operator $[x^n]: $ extracts the coefficient at $x^n $ in the subsequent expression and we have introduced binary vectors $\mathbf a=(a_1,a_2,\cdots, a_C) $ with $a_i=0,1$ equipped with the weight $|\mathbf a|\equiv \sum_i a_i $.

The expected value can then be computed as: $$\bar K(N,m_1,m_2,\dots,m_C)=\sum_{K=0}^CKp_K(N,m_1,m_2,\dots,m_C). $$

The expression can be drastically simplified if one assumes that the numbers of marbles of each color in the jar are equal, but this was not confirmed by the author.

user
  • 26,272