inverse transform method Using Inverse Transform Method to solve parts of the problem below:

(a) Suppose $X \sim \text{Exponential}(λ = 0.2)$. Use RN to generate
  20 random realisations of $X$ $\{X_1, X_2, .., X_{20}\}$ and compute
  their average and standard deviation.
(b) Suppose Y is a discrete random variable with the following
  probability distribution:  $$P(Y = 1) = 0.1,\ P(Y = 2) = 0.5,\ P(Y =
> 3) = 0.25,$$ $$P(Y = 4) = 0.1,\ \ P(Y = 5) = 0.05$$ Repeat part (a)
  for $Y$ using Excel’s rand() function instead of RN.

I am not sure how to start this?  Is the U(0.025, 0.975) or (0,1)?  
 A: (a) The CDF of $\mathsf{EXP}(rate = \lambda = 0.2)$ is $F_X(x) = 1 - e^{-\lambda x},$ for $x > 0.$
Thus the quantile function (inverse CDF) $F_X^{-1}(u)$ is found by
setting $u = 1 - e^{-\lambda x}$ and solving for $x$ in terms of $u$ to obtain
$F_X^{-1}(u) = -\frac{1}{\lambda}\ln(1 - u),$ for $0<u<1.$
Then, for $U \sim \mathsf{Unif}(0,1),$ we have 
$$X = -\frac{1}{\lambda}\ln(1 - U) \sim \mathsf{EXP}(\lambda).$$
Because $1 - U$ is also distributed as $\mathsf{Unif}(0,1),$ this is often simplified
as $X = -\frac{1}{\lambda}\ln(U).$ 
I will use R statistical software to show how to generate $n = 20$ observations
from the distribution $\mathsf{EXP}(\lambda = 0.2)$ by this method. In R, one simulates a sample of size 20 from  the distribution $\mathsf{Unif}(0,1)$ by using the statement 'runif(20)'.
[This is similar to using 'RN' in your software and 'rand()` in Excel; I will leave
the exact syntax to you in each case.]  By setting the seed of the random number
generator, you can repeat the same pseudorandom' results I'm showing below.
set.seed(2020)        # for reproducibility
n = 20;  u = runif(n) # simulate 20 standard uniform obs.
x = -(1/0.2)*log(u)   # transform to simulate 20 exponential obs.
mean(x);  sd(x)
[1] 5.553993  # sample mean of x's
[1] 6.651579  # sample SD of x's

One can show by calculus that the mean and standard deviation of $\mathsf{EXP}(\lambda = 0.2)$ are $\mu = \sigma = 1/0.2 = 5.$ So the sample mean and SD are about as
near to the population mean and SD as can be anticipated from a sample as small as $n = 20.$ 
By the Law of Large Numbers such estimates get better as $n$ increases.
If I use samples of size one million $(n = 10^6)$ in the program above, I get sample
mean $\bar X = 4.995758$ and sample SD $S =4.991709.$ A histogram (blue) of this large sample is shown below along with the density function (orange) of $\mathsf{EXP}(\lambda = 0.2).$

(b) The general idea is the same, but the CDF is a step function, so you will have to find its inverse 'piece-by-piece'.
