# Simulation in statistics

If 0.1178, 0.7843, 0.8713, 0.5472, 0.6977 are five simulated values from a U [0, 1] distribution, simulate five values from a Bin(7, 0.3) distribution.

I'm going to be honest, I have tried to look up online what simulation exactly is, but I still don't understand it. If anyone can provide a good explanation as to what it actually is, and walk through the question above, I'd be grateful.

Thanks

The binomial distribution with the parameters $n=5$ and $p=0.3$ can take values from the set $\{0,1,2,\ldots,7\}$ with the positive probabilities given by the formula $$\binom 7 k 0.3^k(1-0.3)^{7-k}$$ and equal to $$\begin{array}{|c|c|c|c|c|c|c|c|}\hline k & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 \\\hline P(X=k) &0.0824& 0.2471 &0.3177 &0.2269 &0.0972 &0.0250 &0.0036 &0.0002\\\hline \end{array}.$$
If you want to simulate the binomial distribution using the uniform distribution, one way to do this is to split the interval $[0,1]$ into subintervals such that the probability to obtain a number from the first interval is $P(X=0)$, the probability to obtain a value from the second interval is $P(X=1)$ and so on and so forth. For example, the intervals could be as follows: \begin{align*} [0,0.0824)\ [0.0824,0.3295)\ [0.3295,0.6472)\ [0.6472,0.8741)\\ [0.8741,0.9713)\ [0.9713,0.9963)\ [0.9963,0.9998)\ [0.9998,1]. \end{align*}
For example, if you obtain $0.1178$ from the uniform distribution, then that means that you obtain $1$ from the binomial distribution because $0.1178$ falls into the second interval.