Title: Random numbers from an arbitrary distribution SSP 5
1Lecture 8
- Random numbers from an arbitrary distribution
(SSP 5)
2Distribution xx1 p(x)p1 xx2 p(x)p2 (1-p1)
Call ? if ? lt p1 set xx1 else xx2
Distribution xx1 p(x)p1 xx2 p(x)p2 xx3 p
(x)p3
Call ? if ? lt p1 set xx1 else if ?ltp1p2
xx2 else xx3
3Sampling from a discrete distribution
4Sampling from a continuous distribution, p(x)dx,
a?x?b
Method of inversion Solve P(x)?, where
5Example the exponential distribution
or x -? ln?
6Example The power law distribution
xx0?-1/(?-1)
7Method of Composition
8(No Transcript)
9(No Transcript)
10Von Neumanns method
To select from p(x)dx, a?x?b
Write p(x)dxC Q(x) ?(x)dx, Where maxQ(x)1
11Von Neumanns Acceptance-Rejection algorithm
?(x) the sampling, or targeting function, must
be a distribution which can be easily
sampled, should mimic p(x) as far as possible so
acceptance is high Q(x) the acceptance function
12Good and not so good sampling functions
13Method of Superposition
Write p(x)dx in the form,
14Example Angular distribution in Thompson
scattering
is a probability distribution,
15Show that the algorithm is If ?1 lt ¾ set x2 ?2-1
else set x?(2 ?2 1)1/3, the sign chosen at
random.