Rejection sampling is a basic technique used to generate observations from a distribution. It is also commonly called the acceptance-rejection method or “accept-reject algorithm.” If the user has a function he or she is trying to sample from, whose functional form is well known, basically accept the sample by generating a uniform random number at any x and accept it if the value if below the value of the function at that x.
The process:
Draw x uniformly from [Xmin, Xmax]
Draw y uniformly from [0, Ymax]
if y < f(x), accept the sample
otherwise reject it
repeat
roxygen2::roxygenise()
?rvsample
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.