mirror of
https://github.com/vale981/phys512
synced 2025-03-04 09:11:37 -05:00
Update discussion of rejection method
This commit is contained in:
parent
e3be14774c
commit
be7cdcd4b1
1 changed files with 1 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue