# Relationship among exponential distribution, sample size is n, allowed deviation from population mean is X%, then probability of this is %P

I performed monte carlo simulation for various sample sizes with exponential distribution.

I set "allowed deviation from population mean" as $$5\%$$. I iterated $$1E5$$ times for each sample size. I performed for various rate (or mu) parameters and observed the table below:

Independent of the rate (or mu) parameter value,

• if for example my sample size is $$7$$ then, my chance that my only sample is within $$±5\%$$ range of population mean is nearly $$10.58\%$$.
• If my sample size is $$200$$ then, my chance that my only sample is within $$±5\%$$ range of population mean is nearly $$51.70\%$$ etc.

my question

What is the distribution in my table? I observed these relations by monte carlo simulation but how would I find these results with analytical methods?

my matlab code & result:

clear
clc
format long

x=1E5;
mu=100;
m0=[1 7 10 20 30 42 50 100 200 300 400 600 800 1000 1200 1400 1600 1800 2000];
risk=0.05;

output = zeros(length(m0),2);
lb=(1-risk)*mu;
ub=(1+risk)*mu;
for j=1:length(m0)
ss= m0(1,j);
m1=mu*-log(rand(ss,x));
column_means = mean(m1,1);
clear m1;
flags=zeros(1,x);
for i=1:x
if(column_means(1,i)>=lb && column_means(1,i)<=ub)
flags(1,i) = 1;
end
end
output(j,1)=ss;
output(j,2)=mean(flags);
end
disp(output);

ss: sample size

ss     Probability that sample is within +-5% range ([95, 105]) of population mean
--     ---------------------------------------------------------------
1      0.035730000000
7      0.105830000000
10     0.123500000000
20     0.177420000000
30     0.216290000000
42     0.253500000000
50     0.273810000000
100    0.382380000000
200    0.517070000000
300    0.611890000000
400    0.683560000000
600    0.779030000000
800    0.843180000000
1000   0.885190000000
1200   0.916360000000
1400   0.939380000000
1600   0.955580000000
1800   0.965080000000
2000   0.974480000000


You've got $$X_1,\ldots,X_n \sim \mathrm{Exp}(\mu)$$ (where $$\mu$$ is the scale parameter) and you're interested in the probability $$\mathrm{P}(0.95\mu<\bar{X}<1.05\mu)$$.

For $$n=1$$, we have $$\bar{X}=X_1$$ so this is just $$F_{X_1}(1.05\mu)-F_{X_1}(0.95\mu)=(1-\exp(-1.05\mu/\mu))-(1-\exp(-0.95\mu/\mu))\approx 0.0368,$$ which is close to the value you found by simulating ($$0.03573$$).

For $$n>1$$, we need to use two standard results: if $$X_i \sim\mathrm{Exp}(\mu)$$ and $$c>0$$ then $$\frac{X_i}{c} \sim \mathrm{Exp}(\frac{\mu}{c})$$, and the sum of $$k$$ independent $$\mathrm{Exp}(\theta)$$ is distributed as $$\mathrm{Gamma}(k,\theta)$$. Putting the two together, we deduce that $$\bar{X}=\frac{X_1}{n}+\ldots+ \frac{X_n}{n}\sim \mathrm{Gamma}(n,\frac{\mu}{n})$$ or, equivalently, $$\frac{\bar{X}}{\mu} \sim\mathrm{Gamma}(n,\frac{1}{n})$$.

If $$Y=\frac{\bar{X}}{\mu}$$, the probability we want is $$F_Y(1.05)-F_Y(0.95)$$, where $$F_Y$$ is the appropriate Gamma CDF. This does not have a closed form, but you can use the gamcdf function in Matlab (https://uk.mathworks.com/help/stats/gamcdf.html).

For the first few values you specified, I get:

 ss         prob
1   0.03680327
7   0.10408459
10   0.12469342
20   0.17634462
30   0.21538335
42   0.25378748
50   0.27608289

• May you please add a comment or edit your question to explain for example: while sample size is $10$, how you exactly find $0.12469342$ in Matlab? This will make me to read the literature deeply to understand truly. thanks. Oct 26, 2022 at 4:51
• I added a more detailed explanation. Hope it makes sense. Oct 27, 2022 at 7:58