How functions like rnorm in R (and similar functions) create a random sample ? If I want to implement one algorithm to simulate this procedure what can I do? When you have the pdf or pmf of a distribution how can you use this to create a random sample with a computer? Is there some book on this topic?Is this a numerical analysis topic? I searched alot but I couldn't find any information about this.
-
$\begingroup$ If you can sample a $U(0,1)$ random variable, apply the inverse CDF of a random variable to get a sample of it. For Gaussians there are other options, see for example this question. $\endgroup$– Yuval FilmusApr 8, 2020 at 18:44
1 Answer
One standard approach is to use inverse transform sampling: if $F$ is the cdf of the desired random variable and $U$ is uniformly distributed, then $F^{-1}(U)$ has the desired distribution. There are more sophisticated methods for specific distributions; you can find references and links where you can learn more in the linked Wikipedia article.