STAT 380 Lecture 26
Example: Half normal distribution: X has density
(Density of absolute value of N(0,1).)
Use
. To find c maximize
Rewrite as
Maximum is at x=a giving
Choose a to minimize c (or
); get
a=1 so
Algorithm is then: generate
and
then compute
Generate
and if
accept Y otherwise try again.
To generate N(0,1): use a third U to pick a sign at random: negative if u < 1/2 otherwise positive.
Discrete Distributions
The inverse transformation method works for discrete distributions.
X has possible values
with
probabilities
compute
cumulative probabilities
with
.
Generate
Uniform(0,1).
Find k such that
Put
.