If the random variable YY is a
monotonic increasing function of random variable
XX such that
Y=gX
Y
g
X
and
X=g-1Y
X
g
Y
(inversion of
g.
g
.
requires it to be monotonic) then, given the cdf
F
X
x
F
X
x
and the function
g.
g
.
, what are
F
Y
y
F
Y
y
and
f
Y
y
f
Y
y
, the cdf and pdf of
Y
Y?
If
g.
g
.
is monotonic increasing, the cdf of
YY is given by
F
Y
y=PrY≤y=PrgX≤gx=PrX≤x=
F
X
x
F
Y
y
Y
y
g
X
g
x
X
x
F
X
x
(1)
where
y=gx
y
g
x
.
The pdf of YY may be found as
follows:
f
Y
y=ddy
F
Y
y=ddy
F
X
x=ddx
F
X
xddyx=
f
X
xddyx
f
Y
y
y
F
Y
y
y
F
X
x
x
F
X
x
y
x
f
X
x
y
x
(2)
Defining
ddxy=g′x
x
y
g
x
and
f
Y
y=
f
X
xg′x
f
Y
y
f
X
x
g
x
This relation is illustrated in
Figure 1, using a geometric construction to relate
f
Y
f
Y
to
f
X
f
X
via
Y=gX
Y
g
X
. The area under each of the pdfs between a given
pair of dashed lines must be the same, because the
probability of being in a given range of
XX must be the same as the
probability of being in the equivalent range of
YY.
If
g.
g
.
is monotonic decreasing (instead of increasing),
then Equation 1 becomes
F
Y
y=PrgX≤gx=PrX≥x=1−
F
X
x
F
Y
y
g
X
g
x
X
x
1
F
X
x
(3)
and by a similar argument we find that
f
Y
y=
f
X
x-g′x
f
Y
y
f
X
x
g
x
(4)
In principle, any
non-monotonic function
g.
g
.
can be split into a finite number of monotonic sections and in that case the pdf result can be generalized to
f
Y
y=∑i
f
X
x|g′x||x=
x
i
f
Y
y
i
x
x
i
f
X
x
g
x
(5)
where the
x
i
x
i
are all the solutions of
gx=y
g
x
y
at any given
y
y. However care is needed in this case, because if
gx
g
x
is smooth then
g′x
g
x
will become zero at the section boundaries and so
f
Y
y
f
Y
y
will tend to infinity at these points.
If XX has a uniform pdf from
00 to
11 (and zero elsewhere), and we
wish to generate YY using
Y=gX
Y
g
X
such that YY
has a Gaussian (normal) pdf of unit variance and zero mean, what is the required function
g.
g
.
?
(This function is often needed in computers, because standard random number generators tend to have uniform pdfs, while simulation of noise from the real world requires Gaussian pdfs.)
For these pdfs:
f
X
x=1if0≤x≤10otherwise
f
X
x
1
0
x
1
0
(6)
f
Y
y=12πⅇ-y22
f
Y
y
1
2
y
2
2
(7)
The corresponding cdfs are
F
X
x=∫-∞x
f
X
udu=0ifx<0xif0≤x≤11ifx>1
F
X
x
u
x
f
X
u
0
x
0
x
0
x
1
1
x
1
(8)
F
Y
y=∫-∞y
f
Y
udu
F
Y
y
u
y
f
Y
u
(9)
From our previous analysis, if
0≤g-1y≤1
0
g
y
1
F
Y
y=
F
X
g-1y=g-1y
F
Y
y
F
X
g
y
g
y
(10)
So,
g-1y=∫-∞y
f
Y
udu
g
y
u
y
f
Y
u
(11)
This integral has no analytic solution, so we cannot easily
invert this result to get
g.
g
.
. However a numerical (or graphical) solution is
shown in
Figure 2(a).
We can get an analytic solution to this problem as follows. If
we generate a 2-D Gaussian from polar coordinates, we need to
use two random variables to generate
rr and
θθ with the
correct distributions. In particular,
rr requires a Rayleigh
distribution which can be
integrated analytically and hence gives a relatively simple
analytic solution for
g.
g
.
.
Assuming we start with a uniform pdf from
00 to
11 as before,
generating θθ is easy as we
just scale the variable by
2π
2
to get random phases uniformly distributed from
00 to
2π
2
.
Once we have
rθ
r
θ
, we can convert to Cartesian components
x
1
x
2
x
1
x
2
to obtain two variables with Gaussian pdfs.
To generate rr correctly, we need
a Rayleigh pdf
f
R
r=rⅇ-r22ifr≥00otherwise
f
R
r
r
r
2
2
r
0
0
(12)
So,
g-1y=∫-∞y
f
R
rdr=∫0yrⅇ-r22dr=-ⅇ-r22|0y=1−ⅇ-y22
g
y
r
y
f
R
r
r
0
y
r
r
2
2
0
y
r
2
2
1
y
2
2
(13)
To get
y=gx
y
g
x
, we just invert the formula for
x=g-1y
x
g
y
. Hence
x=1−ⅇ-y22
x
1
y
2
2
-y22=ln1−x
y
2
2
1
x
∀x,0≤x<1:y=gx=-2ln1−x
x
0
x
1
y
g
x
-2
1
x
(14)
This conversion is illustrated in
Figure 2(b).
Summarizing the complete algorithm:
-
Generate a 2-D random vector
x=
x
1
x
2
T
x
x
1
x
2
with uniform pdfs from
00T
0
0
to
11T
1
1
, by two calls to a standard random number generator function (e.g. rand() in Matlab; although this whole procedure is unnecessary in Matlab as there is already a Gaussian random generator, randn()).
-
Convert
x
1
x
1
into rr with
Rayleigh pdf using
r=g
x
1
=-2ln1−
x
1
r
g
x
1
-2
1
x
1
(15)
-
Convert
x
2
x
2
into θθ with
uniform pdf from 00 to
2π
2
using
θ=2π
x
2
θ
2
x
2
(16)
-
Generate two independent random variables with Gaussian
pdfs of unit variance and zero mean using
y
1
=rcosθ
y
1
r
θ
and
y
2
=rsinθ
y
2
r
θ
-
Repeat steps 1 to 4 for each new pair of variables required.
y
1
y
1
and
y
2
y
2
may be scaled by
σσ to adjust their
variance, and an offset may be added in order to produce a
non-zero mean.