Skip to content Skip to navigation

Connexions

You are here: Home » Content » Functions of Random Variables

Navigation

Content Actions

  • Download module PDF
  • Add to ...
    Add the module to:
    • My Favorites
    • A lens
    • An external social bookmarking service
    • My Favorites (What is 'My Favorites'?)
      'My Favorites' is a special kind of lens which you can use to bookmark modules and collections directly in Connexions. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need a Connexions account to use 'My Favorites'.
    • A lens (What is a lens?)

      Definition of a lens

      Lenses

      A lens is a custom view of Connexions content. You can think of it as a fancy kind of list that will let you see Connexions through the eyes of organizations and people you trust.

      What is in a lens?

      Lens makers point to Connexions materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

      Who can create a lens?

      Any individual Connexions member, a community, or a respected organization.

      What are tags? tag icon

      Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

    • External bookmarks
  • E-mail the author
  • Rate this module (How does the rating system work?)

    Rating system

    Ratings

    Ratings allow you to judge the quality of modules. If other users have ranked the module then its average rating is displayed below. Ratings are calculated on a scale from one star (Poor) to five stars (Excellent).

    How to rate a module

    Hover over the star that corresponds to the rating you wish to assign. Click on the star to add your rating. Your rating should be based on the quality of the content. You must have an account and be logged in to rate content.

    (0 ratings)

Recently Viewed

This feature requires Javascript to be enabled.

Functions of Random Variables

Module by: Nick Kingsbury

Summary: This module introduces functions of random variables.

Note: Your browser may not currently support MathML. See our browser support page for additional details. You can always view the correct math in the PDF version.

Problem:

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?

Solution:

If g. g . is monotonic increasing, the cdf of YY is given by

F Y y=PrYy=PrgXgx=PrXx= 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=gx x y g x and f Y y= f X xgx 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.

Figure 1: Illustration of monotonic mapping of pdfs by plotting f Y y f Y y rotated by 90°. The non-linearity in this case is gX=0.4X2+X0.4 g X 0.4 X 2 X 0.4 , which is monotonic for -1X1 -1 X 1 .
Figure 1 (figure1.png)

If g. g . is monotonic decreasing (instead of increasing), then Equation 1 becomes

F Y y=PrgXgx=PrXx=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-gx 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|gx||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 gx g x will become zero at the section boundaries and so f Y y f Y y will tend to infinity at these points.

Example - Generation of a Gaussian pdf from a uniform pdf

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=1if0x10otherwise 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<0xif0x11ifx>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 0g-1y1 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).

Figure 2: Conversion of uniform pdf to (a) a Gaussian pdf and (b) a Rayleigh pdf. A numerical solution for gX g X was required for (a) in order to invert Equation 11, whereas (b) uses the analytic solution for gX g X , given in Equation 14.
(a)
Figure 2(a) (figure2a.png)
(b)
Figure 2(b) (figure2b.png)

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-r22ifr00otherwise 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=ln1x y 2 2 1 x
x,0x<1:y=gx=-2ln1x x 0 x 1 y g x -2 1 x (14)
This conversion is illustrated in Figure 2(b).

Summarizing the complete algorithm:

  1. 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()).
  2. 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)
  3. Convert x 2 x 2 into θθ with uniform pdf from 00 to 2π 2 using
    θ=2π x 2 θ 2 x 2 (16)
  4. 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 θ
  5. Repeat steps 1 to 4 for each new pair of variables required.

note:

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.

Comments, questions, feedback, criticisms?

Send feedback