1

I have an exercise in statistics in witch I need to generate n values โ€‹โ€‹of a random variable X having the distribution function F ( in excel ). I don't understand how I should do that in excel.

enter image description here

  • 2
    Find the inverse of the cumulative distribution function $F$ and apply that to a uniformly distributed random variable on $(0,1)$. Do this $n$ times โ€“ Henry Mar 21 '22 at 17:06

1 Answers1

0

Excel has this $\texttt{RAND()}$ function which samples from a uniform distribution over $[0,1]$. You can use this in order to sample from other distributions using the following trick.

Let $Y$ be another random variable with uniform distribution function over $[0,1]$. The idea is to sample from $Y$, apply some function $g(Y)$ to it and hopefully obtain something distributed as the given cumulative distribution $F(X)$ you have. Let $X = g(Y)$. We know that both cumulative distributions (of $X$ and $Y$ )must be related as $$ F(x) = \int_0^{y}dy $$ since $Y$ is uniformly distributed. Hence $F(x) = y\in[0,1]$ so that $x = F^{-1}(y)$. In your case: $$ F(x) = 1-e^{-x}\implies F^{-1}(y) = \ln\left(\frac{1}{1-y}\right) $$ Hence, the resulting command would be: $$\texttt{=ln(1/(1-RAND()))}$$

Hope this helps.