# 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 $N$ i.i.d. samples of $X$, where $N$ is $Binomial(n, p)$. Any time I read about confidence intervals for the mean it is assumed that the number of samples 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 $N$ 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 \left(\begin{array}{cc}n\\\i\end{array}\right)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 only when $X$ is normally distributed or 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 Chevychev'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

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.

-