I have been trying to construct a $1-\alpha$ confidence interval for the mean. The distribution from which a sample is drawn is exponential distribution with density:
$$p(x) = \frac{1}{\beta}e^{-x/\beta}$$
The exponential distribution has mean $\mu=\beta$ and standard deviation $\sigma=\beta$. As far as my knowledge is concerned, for a sample $X_1, X_2, \cdots, X_n$ of size $n$, the confidence interval :
$$\left(\bar{X}_n-z_{\alpha/2}\frac{\sigma}{\sqrt{n}}, \bar{X}_n+z_{\alpha/2}\frac{\sigma}{\sqrt{n}}\right)$$
should trap the true $\mu$ with $1-\alpha$ chance (I am not saying that this interval contains $\mu$ with probability $1-\alpha$; that will be wrong since $\mu$ is not a random variable).
However, this assumes that population standard deviation $\sigma$ is known. Since I want to simulate a situation where that too needs to be estimated, I constructed the forllowing interval:
$$\left(\bar{X}_n-t_{\alpha/2}\frac{\hat{\sigma}}{\sqrt{n}}, \bar{X}_n+t_{\alpha/2}\frac{\hat{\sigma}}{\sqrt{n}}\right)$$
where, $$\hat{\sigma}=\sqrt{\frac{1}{n-1}\sum_{i=1}^n (X_i-\bar{X}_n)^2}$$
and $t_{\alpha/2}$ is the critical t-value obtained for the Student's t-distribution for $n-1$ degrees of freedom.
I wrote a small python script to verify that with this modification, the constructed interval is indeed $95\%$ confidence interval when $\alpha=0.05$. For my simulations, I chose $n=10$, so that we have $9$ degrees of freedom, $t_{\alpha/2}=2.262$. I could verify that the first interval where population variance is known indeed contains true $\mu$ around $95\%$ of the time. (I generate $10000$ intervals and count how many contain the known $\mu$). However, the second one seems to contain $\mu$ only $90\%$ of the time. I am not sure why even after correctly choosing the correct critical $t$ this is happening. If I increase $t_{\alpha/2}=3.182$ corresponding to 3 degrees of freedom, I do get $95\%$ interval again! But of course this makes no sense because the degrees of freedom is $9$ in this case. Any idea what is happening?