# Confidence intervals when the number of samples is random

I am interested in computing confidence intervals for the mean of a random variable $X$ given $\require{cancel}\xcancel{N \text{ i.i.d. samples}}$ an i.i.d. sample of $N$ copies of $X$, where $N$ is $\operatorname{Binomial}(n, p)$. Any time I read about confidence intervals for the mean it is assumed that the number of samplessize of the sample is fixed, which makes the asymptotic distribution of the sample mean Gaussian, and therefore allows for student-based confidence intervals and the like to be justified. However, if the number of samples size $N$ of the sample is a random variable itself, then the ratio $$\frac{\sum_i X_i}{N}$$ will not be necessarily normal (see, for instance, http://en.wikipedia.org/wiki/Ratio_distribution#Gaussian_ratio_distribution).

What is the best way to deal with this scenario? Will bootstrapping be theoretically justified in this case?

Let $\hat{\mu}=\frac{\sum_i X_i}{N}$ and $\mu = \mathbf{E}(X)$

$$\mathcal{P}(\mu \in [x,y]\,|\, a) = \sum_i \binom ni p^i(1-p)^{n-i}\mathcal{P}(\mu \in [x,y]\,|\,a,N=i)$$

If $pN$ is relatively large, and $\hbox{var}(X) = \sigma^2$ you can represent the true mean as taken from a mixture of gaussian with mean $a$ and variance $\sigma^2/N$. This is not gaussian, but you can compute the pdf.

While the mixture isn't gaussian, you can compute its variance as

$$\sigma^2 \frac{np(1-p)^{n-1} F_{3,2}\left(1,1,1-n;2,2;\frac{p}{p-1}\right)}{1-(1-p)^n}$$

(N.B this only valid when $X$ is normally distributed or approximately valid when $n >> (1-p)/p$) $F_{3,2}$ is the hypergeometric function

For $p = 0.25$ and $N=100$ your average has about $4.13\%$ of the variance of $X$

You can then use conservatively Chebyshev's inequality.

• Why are you ignoring the question of whether the sample size is part of the observable data? – Michael Hardy Mar 25 '11 at 22:12
• I am not, the whole point of this answer is that I marginalize over N. – Arthur B Mar 23 '12 at 18:32
• I don't understand the parenthetical statement. $F_{3,2}$ is the hypergeometric function only for certain $X$ and certain values of $n$? Then what is $F_{3,2}$ in the other cases? I never heard of any other functions for which this notation was used. – Vincent Mar 2 '18 at 10:24
• Poorly phrased, I mean that the formula is only valid for X normally distributed, or approximately valid for n >> (1-p)/p F_{3,2} is always the hypergeometric function. Editing to replace the , with a . – Arthur B Mar 2 '18 at 15:13

You should speak of the size of the sample, rather than of the number of samples.

You haven't said whether you can actually observe the sample size. Nor whether the probability distribution of the sample size in any way depends on the mean that you're trying to estimate. If you can observe the sample size and if you know it doesn't depend on that which you're trying to estimate, then it is an ancillary statistic (see http://en.wikipedia.org/wiki/Ancillary_statistic) and you can in effect treat it as non-random by conditioning on it.