|
Acceptance-rejection:
a cosine
Simulates (acc.-rej.) a "cosine density" with a
triangular hat function selected for optimization. |
|
|
method |
|
Transform method. • |
trials, .seed |
× 106 |
N. of ("accepted") trials from distribution
(≤ 2 millions), seed. • |
μ, a |
|
Mean and (positive) half breadth
[x ∈ (μ ± a)]. • |
x0 or z0 |
=
|
Point of tangency of triangular (μ <
x0 ≤ μ + a or 0 <
z0 ≤ 1). • |
klasses |
|
N. of classes (points) for graph. • |
.L, U |
|
Lower and upper limits for probability
verification. • |
Show values |
|
Show the values of the graph coordinates. |
Applies the acceptance-rejection method to simulate
a cosine target density,
f = [π ⁄ (4a)]
cos[(π ⁄ 2)z], |z| ≤ 1,
with z =
(x −μ) ⁄ a, through
a (symmetrical, truncated) triangular instrumental density.
The "constant" c for the hat function, a "roof", can be
optimized for smallest rejection fraction.
Graphs will be drawn for the various functions.
(For inversion transform, the useless fhat is drawn
coincident with f.). | |
| References: |
Plate simrejcosine |
• Devroye, Luc, 2004, pdf (=), Computational Geometry Lab,
Carlton Univ., Ottawa (Ontario, Canada).
• Random Number Bibliography,
RandomNumber.org .
• 1890-02-17: Fisher,
Sir Ronald A.. |