Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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$.

share|cite|improve this question
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$.

share|cite|improve this answer
Thanks and by different monte carlo estimators we are supposed to use two different 'random distributions' in generating our 1x1000 vector (that gets plugged into x for the simulation) exprnd and randuniform. Since the numbers generated by each of these will have a different probability density it should change, slightly I expect, the answer in the simulation. – Geroge Vandaly Nov 19 '12 at 8:31
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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.