2
$\begingroup$

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.

$\endgroup$
  • $\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 Filmus Apr 8 at 18:44
2
$\begingroup$

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.

| cite | improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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