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 samples~~size 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?



Confidence intervals when the number of samples is random
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](http://en.wikipedia.org/wiki/Chebyshev's_inequality).


