# Exponential Probability Monte Carlo simulation

I need to write a Matlab program to estimate the quantity $\theta = \mathrm{Pr}(X < 1)$, where $X$ is an exponential random variable with mean $1$. I am doing this for multiple monte carlo estimators (using different probability densitys).

If I understand correctly since our distribution has a mean ($\lambda$) of one thus $\theta=\int_0^1 \exp(-x)\,\mathrm dx$, and then I need to generate random samples for monte carlo simulation. I can do this easily with $\mathrm{exprnd}(1,1,1000)$ which will generate a sample of $1000$ random numbers with the mean $1$.

Once I have my random numbers how do I end up with a cumlative probability, what code should I be writing to obtain this last step. Setting $X=-\ln(1-U)$ does not really seem to be helping me (where $X$ is our random variable and $U$ is each observation of the $1\times 1000$ randomly generated vector)

All im asked to do is plot the estimate as functions of n, the number of samples generated so its not calculating an actual $p$.

-
What do you mean by this: "I am doing this for multiple monte carlo estimators (using different probability densitys)."? –  Stefan Hansen Nov 19 '12 at 6:13

If $X=(X_1,\ldots,X_{1000})=\mathrm{exprnd}(1,1,1000)$, then the proportion $$\hat{\theta}=\frac{1}{1000}\sum_{i=1}^{1000} 1_{\{X_i<1\}}$$ estimates the probability $\theta=P(X<1)$ (by the law of large numbers). Now you could repeat this step for $n=10,100,1000,10000$ and so on (i.e. simulate $X=(X_1,\ldots,X_n)=\mathrm{exprnd}(1,1,n)$ and calculate $\hat{\theta}_n$) and plot $\hat{\theta}_n$ as a function of $n$.
I'm still not sure what you mean. Do you mean to look if there is any difference in using $\mathrm{exprnd}(1,1,1)$ compared to $-\log(U)$, where $U\sim \mathrm{Uniform}(0,1)$? –  Stefan Hansen Nov 19 '12 at 8:42