From be7cdcd4b1c0572e16658df705d8684e5623aa53 Mon Sep 17 00:00:00 2001 From: Andrew Cumming Date: Tue, 26 Sep 2023 10:29:54 -0400 Subject: [PATCH] Update discussion of rejection method --- generating_random.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generating_random.md b/generating_random.md index 5ab70ca..7fc9b4b 100644 --- a/generating_random.md +++ b/generating_random.md @@ -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