Update discussion of rejection method

This commit is contained in:
Andrew Cumming 2023-09-26 10:29:54 -04:00
parent e3be14774c
commit be7cdcd4b1

View file

@ -8,7 +8,7 @@ If $f(x)$ is the probability distribution that we want, the rejection method is
For example, consider the distribution $f(x)=\sin x$ for $x=0$ to $x=\pi$ (note that this is normalized to unity as expected for a probability distribution). We choose a set of $(x,y)$ pairs in which $x$ is uniformly-distributed between $0$ and $\pi$, and $y$ is uniformly-distributed between $0$ and $1$ ($1$ is the maximum value of $\sin x$). We keep only the values of $x$ which have a corresponding $y$ that is $y < f(x)$. These $x$-values will be distributed according to $f(x)=\sin x$.
This method is very straightforward to implement, but has the disadvantage that we have to reject some fraction of the sampled points. The rejection fraction can be large if the probability distribution is far from uniform (e.g. very peaked). A way around this is to use another distribution $g(x)$ for generating the test points which lies everywhere above $f(x)$, but is shaped such that a small number of points end up being rejected (this approach is known as **importance sampling**). In this case, we generate $x$-values from $g(x)$, $y$ values uniformly-distributed between 0 and 1, and accept the points which have $y < f(x)/g(x)$.
This method is very straightforward to implement, but has the disadvantage that we have to reject some fraction of the sampled points. The rejection fraction can be large if the probability distribution is far from uniform (e.g. very peaked). A way around this is to use another probability distribution $p(x)$ for generating the $x$-values that follows more closely the shape of $f(x)$, leading to a smaller number of rejected points. (This approach is known as **importance sampling**, we'll come across it again later). In this case, we accept the points which have $y < f(x)/p(x)$, where $y$ is uniformly-distributed (you just have to make sure that $y$ covers a range that includes the maximum value of $f(x)/p(x)$).
## Transformation method