# Connexions

You are here: Home » Content » Applied Probability » Functions of a Random Variable

• Preface to Pfeiffer Applied Probability

### Lenses

What is a lens?

#### Definition of a lens

##### Lenses

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

##### What is in a lens?

Lens makers point to 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 member, a community, or a respected organization.

##### What are tags?

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

#### Affiliated with (What does "Affiliated with" mean?)

This content is either by members of the organizations listed or about topics related to the organizations listed. Click each link to see a list of all content affiliated with the organization.
• Rice Digital Scholarship

This collection is included in aLens by: Digital Scholarship at Rice University

Click the "Rice Digital Scholarship" link to see all content affiliated with them.

#### Also in these lenses

• UniqU content

This collection is included inLens: UniqU's lens
By: UniqU, LLC

Click the "UniqU content" link to see all content selected in this lens.

### Recently Viewed

This feature requires Javascript to be enabled.

Inside Collection:

Collection by: Paul E Pfeiffer. E-mail the author

# Functions of a Random Variable

Module by: Paul E Pfeiffer. E-mail the author

Summary: Frequently, we observe a value of some random variable, but are really interested in a value derived from this by a function rule. If X is a random variable and g is a reasonable function (technically, a Borel function), then Z=g(X)is a new random variable which has the value g(t) for any ω such that X(ω)=t. Thus Z(ω)=g(X(ω)). Suppose we have the distribution for X. How can we determine P(Z∈M), the probability Z takes a value in the set M? Mapping approach. Simply find the amount of probability mass mapped into the set M by the random variable X. In the absolutely continuous case, integrate the density function for X over the set M. In the discrete case, as an alternative, select those possible values for X which are in the set M and add their probabilities. For a Borel function g and set M, determine the set N of all those t which are mapped into M, then determine the probability X is in N as in the previous case.

Introduction

Frequently, we observe a value of some random variable, but are really interested in a value derived from this by a function rule. If X is a random variable and g is a reasonable function (technically, a Borel function), then Z=g(X)Z=g(X) is a new random variable which has the value g(t)g(t) for any ω such that X(ω)=tX(ω)=t. Thus Z(ω)=g(X(ω))Z(ω)=g(X(ω)).

## The problem; an approach

We consider, first, functions of a single random variable. A wide variety of functions are utilized in practice.

### Example 1: A quality control problem

In a quality control check on a production line for ball bearings it may be easier to weigh the balls than measure the diameters. If we can assume true spherical shape and w is the weight, then diameter is kw1/3kw1/3, where k is a factor depending upon the formula for the volume of a sphere, the units of measurement, and the density of the steel. Thus, if X is the weight of the sampled ball, the desired random variable is D=kX1/3D=kX1/3.

### Example 2: Price breaks

The cultural committee of a student organization has arranged a special deal for tickets to a concert. The agreement is that the organization will purchase ten tickets at $20 each (regardless of the number of individual buyers). Additional tickets are available according to the following schedule: • 11-20,$18 each
• 21-30, $16 each • 31-50,$15 each
• 51-100, \$13 each

If the number of purchasers is a random variable X, the total cost (in dollars) is a random quantity Z=g(X)Z=g(X) described by

g ( X ) = 200 + 18 I M 1 ( X ) ( X - 10 ) + ( 16 - 18 ) I M 2 ( X ) ( X - 20 ) g ( X ) = 200 + 18 I M 1 ( X ) ( X - 10 ) + ( 16 - 18 ) I M 2 ( X ) ( X - 20 )
(1)
+ ( 15 - 16 ) I M 3 ( X ) ( X - 30 ) + ( 13 - 15 ) I M 4 ( X ) ( X - 50 ) + ( 15 - 16 ) I M 3 ( X ) ( X - 30 ) + ( 13 - 15 ) I M 4 ( X ) ( X - 50 )
(2)
where M 1 = [ 10 , ) , M 2 = [ 20 , ) , M 3 = [ 30 , ) , M 4 = [ 50 , ) where M 1 = [ 10 , ) , M 2 = [ 20 , ) , M 3 = [ 30 , ) , M 4 = [ 50 , )
(3)

The function rule is more complicated than in Example 1, but the essential problem is the same.

The problem

If X is a random variable, then Z=g(X)Z=g(X) is a new random variable. Suppose we have the distribution for X. How can we determine P(ZM)P(ZM), the probability Z takes a value in the set M?

An approach to a solution

We consider two equivalent approaches

1. To find P(XM)P(XM).
1. Mapping approach. Simply find the amount of probability mass mapped into the set M by the random variable X.
• In the absolutely continuous case, calculate MfXMfX.
• In the discrete case, identify those values ti of X which are in the set M and add the associated probabilities.
2. Discrete alternative. Consider each value ti of X. Select those which meet the defining conditions for M and add the associated probabilities. This is the approach we use in the MATLAB calculations. Note that it is not necessary to describe geometrically the set M; merely use the defining conditions.
2. To find P(g(X)M)P(g(X)M).
1. Mapping approach. Determine the set N of all those t which are mapped into M by the function g. Now if X(ω)NX(ω)N, then g(X(ω))Mg(X(ω))M, and if g(X(ω))Mg(X(ω))M, then X(ω)NX(ω)N. Hence
{ω:g(X(ω))M}={ω:X(ω)N}{ω:g(X(ω))M}={ω:X(ω)N}
(4)
Since these are the same event, they must have the same probability. Once N is identified, determine P(XN)P(XN) in the usual manner (see part a, above).
2. Discrete alternative. For each possible value ti of X, determine whether g(ti)g(ti) meets the defining condition for M. Select those ti which do and add the associated probabilities.

Remark. The set N in the mapping approach is called the inverse image N=g-1(M)N=g-1(M).

### Example 3: A discrete example

Suppose X has values -2, 0, 1, 3, 6, with respective probabilities 0.2, 0.1, 0.2, 0.3 0.2.

Consider Z=g(X)=(X+1)(X-4)Z=g(X)=(X+1)(X-4). Determine P(Z>0)P(Z>0).

SOLUTION

First solution. The mapping approach

g(t)=(t+1)(t-4)g(t)=(t+1)(t-4). N={t:g(t)>0}N={t:g(t)>0} is the set of points to the left of -1-1 or to the right of 4. The X-values -2-2 and 6 lie in this set. Hence

P ( g ( X ) > 0 ) = P ( X = - 2 ) + P ( X = 6 ) = 0 . 2 + 0 . 2 = 0 . 4 P ( g ( X ) > 0 ) = P ( X = - 2 ) + P ( X = 6 ) = 0 . 2 + 0 . 2 = 0 . 4
(5)

Second solution. The discrete alternative

 X = X = -2 0 1 3 6 P X = P X = 0.2 0.1 0.2 0.3 0.2 Z = Z = 6 -4 -6 -4 14 Z > 0 Z > 0 1 0 0 0 1

Picking out and adding the indicated probabilities, we have

P ( Z > 0 ) = 0 . 2 + 0 . 2 = 0 . 4 P ( Z > 0 ) = 0 . 2 + 0 . 2 = 0 . 4
(6)

In this case (and often for “hand calculations”) the mapping approach requires less calculation. However, for MATLAB calculations (as we show below), the discrete alternative is more readily implemented.

### Example 4: An absolutely continuous example

Suppose XX uniform [-3,7][-3,7]. Then fX(t)=0.1,-3t7fX(t)=0.1,-3t7 (and zero elsewhere). Let

Z = g ( X ) = ( X + 1 ) ( X - 4 ) Z = g ( X ) = ( X + 1 ) ( X - 4 )
(7)

Determine P(Z>0)P(Z>0).

SOLUTION

First we determine N={t:g(t)>0}N={t:g(t)>0}. As in Example 3, g(t)=(t+1)(t-4)>0g(t)=(t+1)(t-4)>0 for t<-1t<-1 or t>4t>4. Because of the uniform distribution, the integral of the density over any subinterval of [-3,7][-3,7] is 0.1 times the length of that subinterval. Thus, the desired probability is

P ( g ( X ) > 0 ) = 0 . 1 [ ( - 1 - ( - 3 ) ) + ( 7 - 4 ) ] = 0 . 5 P ( g ( X ) > 0 ) = 0 . 1 [ ( - 1 - ( - 3 ) ) + ( 7 - 4 ) ] = 0 . 5
(8)

We consider, next, some important examples.

### Example 5: The normal distribution and standardized normal distribution

To show that if XN(μ,σ2)XN(μ,σ2) then

Z = g ( X ) = X - μ σ N ( 0 , 1 ) Z = g ( X ) = X - μ σ N ( 0 , 1 )
(9)

VERIFICATION

We wish to show the denity function for Z is

φ ( t ) = 1 2 π e - t 2 / 2 φ ( t ) = 1 2 π e - t 2 / 2
(10)

Now

g ( t ) = t - μ σ v iff t σ v + μ g ( t ) = t - μ σ v iff t σ v + μ
(11)

Hence, for given M=(-,v]M=(-,v] the inverse image is N=(-,σv+μ]N=(-,σv+μ], so that

F Z ( v ) = P ( Z v ) = P ( Z M ) = P ( X N ) = P ( X σ v + μ ) = F X ( σ v + μ ) F Z ( v ) = P ( Z v ) = P ( Z M ) = P ( X N ) = P ( X σ v + μ ) = F X ( σ v + μ )
(12)

Since the density is the derivative of the distribution function,

f Z ( v ) = F Z ' ( v ) = F X ' ( σ v + μ ) σ = σ f X ( σ v + μ ) f Z ( v ) = F Z ' ( v ) = F X ' ( σ v + μ ) σ = σ f X ( σ v + μ )
(13)

Thus

f Z ( v ) = σ σ 2 π exp [ - 1 2 σ v + μ - μ σ 2 = 1 2 π e - v 2 / 2 = φ ( v ) f Z ( v ) = σ σ 2 π exp [ - 1 2 σ v + μ - μ σ 2 = 1 2 π e - v 2 / 2 = φ ( v )
(14)

We conclude that ZN(0,1)ZN(0,1)

### Example 6: Affine functions

Suppose X has distribution function FX. If it is absolutely continuous, the corresponding density is fX. Consider Z=aX+b(a0)Z=aX+b(a0). Here g(t)=at+bg(t)=at+b, an affine function (linear plus a constant). Determine the distribution function for Z (and the density in the absolutely continuous case).

SOLUTION

F Z ( v ) = P ( Z v ) = P ( a X + b v ) F Z ( v ) = P ( Z v ) = P ( a X + b v )
(15)

There are two cases

• a>0a>0:
FZ(v)=PXv-ba=FXv-baFZ(v)=PXv-ba=FXv-ba
(16)
• a<0a<0
FZ(v)=PXv-ba=PX>v-ba+PX=v-baFZ(v)=PXv-ba=PX>v-ba+PX=v-ba
(17)
So that
FZ(v)=1-FXv-ba+PX=v-baFZ(v)=1-FXv-ba+PX=v-ba
(18)

For the absolutely continuous case, PX=v-ba=0PX=v-ba=0, and by differentiation

• for a>0fZ(v)=1afXv-baa>0fZ(v)=1afXv-ba
• for a<0fZ(v)=-1afXv-baa<0fZ(v)=-1afXv-ba

Since for a<0a<0, -a=|a|-a=|a|, the two cases may be combined into one formula.

f Z ( v ) = 1 | a | f X v - b a f Z ( v ) = 1 | a | f X v - b a
(19)

### Example 7: Completion of normal and standardized normal relationship

Suppose ZN(0,1)ZN(0,1). Show that X=σZ+μ(σ>0)X=σZ+μ(σ>0) is N(μ,σ2)N(μ,σ2).

VERIFICATION

Use of the result of Example 6 on affine functions shows that

f X ( t ) = 1 σ φ t - μ σ = 1 σ 2 π exp - 1 2 t - μ σ 2 f X ( t ) = 1 σ φ t - μ σ = 1 σ 2 π exp - 1 2 t - μ σ 2
(20)

### Example 8: Fractional power of a nonnegative random variable

Suppose X0X0 and Z=g(X)=X1/aZ=g(X)=X1/a for a>1a>1. Since for t0t0, t1/at1/a is increasing, we have 0t1/av0t1/av iff 0tva0tva. Thus

F Z ( v ) = P ( Z v ) = P ( X v a ) = F X ( v a ) F Z ( v ) = P ( Z v ) = P ( X v a ) = F X ( v a )
(21)

In the absolutely continuous case

f Z ( v ) = F Z ' ( v ) = f X ( v a ) a v a - 1 f Z ( v ) = F Z ' ( v ) = f X ( v a ) a v a - 1
(22)

### Example 9: Fractional power of an exponentially distributed random variable

Suppose XX exponential (λ)(λ). Then Z=X1/aZ=X1/a Weibull (a,λ,0)(a,λ,0).

According to the result of Example 8,

F Z ( t ) = F X ( t a ) = 1 - e - λ t a F Z ( t ) = F X ( t a ) = 1 - e - λ t a
(23)

which is the distribution function for ZZ Weibull (a,λ,0)(a,λ,0).

### Example 10: A simple approximation as a function of X

If X is a random variable, a simple function approximation may be constructed (see Distribution Approximations). We limit our discussion to the bounded case, in which the range of X is limited to a bounded interval I=[a,b]I=[a,b]. Suppose I is partitioned into n subintervals by points ti, 1in-11in-1, with a=t0a=t0 and b=tnb=tn. Let Mi=[ti-1,ti)Mi=[ti-1,ti) be the ith subinterval, 1in-11in-1 and Mn=[tn-1,tn]Mn=[tn-1,tn]. Let Ei=X-1(Mi)Ei=X-1(Mi) be the set of points mapped into Mi by X. Then the Ei form a partition of the basic space Ω. For the given subdivision, we form a simple random variable Xs as follows. In each subinterval, pick a point si,ti-1si<tisi,ti-1si<ti. The simple random variable

X s = i = 1 n s i I E i X s = i = 1 n s i I E i
(24)

approximates X to within the length of the largest subinterval Mi. Now IEi=IMi(X)IEi=IMi(X), since IEi(ω)=1IEi(ω)=1 iff X(ω)MiX(ω)Mi iff IMi(X(ω))=1IMi(X(ω))=1. We may thus write

X s = i = 1 n s i I M i ( X ) , a function of X X s = i = 1 n s i I M i ( X ) , a function of X
(25)

## Use of MATLAB on simple random variables

For simple random variables, we use the discrete alternative approach, since this may be implemented easily with MATLAB. Suppose the distribution for X is expressed in the row vectors X and PXPX.

• We perform array operations on vector X to obtain
G=[g(t1)g(t2)g(tn)]G=[g(t1)g(t2)g(tn)]
(26)
• We use relational and logical operations on G to obtain a matrix M which has ones for those ti (values of X) such that g(ti)g(ti) satisfies the desired condition (and zeros elsewhere).
• The zero-one matrix M is used to select the the corresponding pi=P(X=ti)pi=P(X=ti) and sum them by the taking the dot product of M and PXPX.

### Example 11: Basic calculations for a function of a simple random variable

X = -5:10;                     % Values of X
PX = ibinom(15,0.6,0:15);      % Probabilities for X
G = (X + 6).*(X - 1).*(X - 8); % Array operations on X matrix to get G = g(X)
M = (G > - 100)&(G < 130);     % Relational and logical operations on G
PM = M*PX'                     % Sum of probabilities for selected values
PM =  0.4800
disp([X;G;M;PX]')              % Display of various matrices (as columns)
-5.0000   78.0000    1.0000    0.0000
-4.0000  120.0000    1.0000    0.0000
-3.0000  132.0000         0    0.0003
-2.0000  120.0000    1.0000    0.0016
-1.0000   90.0000    1.0000    0.0074
0   48.0000    1.0000    0.0245
1.0000         0    1.0000    0.0612
2.0000  -48.0000    1.0000    0.1181
3.0000  -90.0000    1.0000    0.1771
4.0000 -120.0000         0    0.2066
5.0000 -132.0000         0    0.1859
6.0000 -120.0000         0    0.1268
7.0000  -78.0000    1.0000    0.0634
8.0000         0    1.0000    0.0219
9.0000  120.0000    1.0000    0.0047
10.0000  288.0000         0    0.0005
[Z,PZ] = csort(G,PX);          % Sorting and consolidating to obtain
disp([Z;PZ]')                  % the distribution for Z = g(X)
-132.0000    0.1859
-120.0000    0.3334
-90.0000    0.1771
-78.0000    0.0634
-48.0000    0.1181
0    0.0832
48.0000    0.0245
78.0000    0.0000
90.0000    0.0074
120.0000    0.0064
132.0000    0.0003
288.0000    0.0005
P1 = (G<-120)*PX '           % Further calculation using G, PX
P1 =  0.1859
p1 = (Z<-120)*PZ'            % Alternate using Z, PZ
p1 =  0.1859


### Example 12

X=10IA+18IB+10ICX=10IA+18IB+10IC with {A,B,C}{A,B,C} independent and P=[0.60.30.5]P=[0.60.30.5].

We calculate the distribution for X, then determine the distribution for

Z = X 1 / 2 - X + 50 Z = X 1 / 2 - X + 50
(27)
c = [10 18 10 0];
pm = minprob(0.1*[6 3 5]);
canonic
Enter row vector of coefficients  c
Enter row vector of minterm probabilities  pm
Use row matrices X and PX for calculations
Call for XDBN to view the distribution
disp(XDBN)
0    0.1400
10.0000    0.3500
18.0000    0.0600
20.0000    0.2100
28.0000    0.1500
38.0000    0.0900
G = sqrt(X) - X + 50;       % Formation of G matrix
[Z,PZ] = csort(G,PX);       % Sorts distinct values of g(X)
disp([Z;PZ]')               % consolidates probabilities
18.1644    0.0900
27.2915    0.1500
34.4721    0.2100
36.2426    0.0600
43.1623    0.3500
50.0000    0.1400
M = (Z < 20)|(Z >= 40)      % Direct use of Z distribution
M =    1     0     0     0     1     1
PZM = M*PZ'
PZM =  0.5800


Remark. Note that with the m-function csort, we may name the output as desired.

### Example 13: Continuation of Example 12, above.

H = 2*X.^2 - 3*X + 1;
[W,PW] = csort(H,PX)
W  =     1      171     595     741    1485    2775
PW =  0.1400  0.3500  0.0600  0.2100  0.1500  0.0900


### Example 14: A discrete approximation

Suppose X has density function fX(t)=12(3t2+2t)fX(t)=12(3t2+2t) for 0t10t1. Then FX(t)=12(t3+t2)FX(t)=12(t3+t2). Let Z=X1/2Z=X1/2. We may use the approximation m-procedure tappr to obtain an approximate discrete distribution. Then we work with the approximating random variable as a simple random variable. Suppose we want P(Z0.8)P(Z0.8). Now Z0.8Z0.8 iff X0.82=0.64X0.82=0.64. The desired probability may be calculated to be

P ( Z 0 . 8 ) = F X ( 0 . 64 ) = ( 0 . 64 3 + 0 . 64 2 ) / 2 = 0 . 3359 P ( Z 0 . 8 ) = F X ( 0 . 64 ) = ( 0 . 64 3 + 0 . 64 2 ) / 2 = 0 . 3359
(28)

Using the approximation procedure, we have

tappr
Enter matrix [a b] of x-range endpoints  [0 1]
Enter number of x approximation points  200
Enter density as a function of t  (3*t.^2 + 2*t)/2
Use row matrices X and PX as in the simple case
G = X.^(1/2);
M = G <= 0.8;
PM = M*PX'
PM =   0.3359       % Agrees quite closely with the theoretical


## Content actions

PDF | EPUB (?)

### What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

PDF | EPUB (?)

### What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

#### Collection to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

#### Definition of a lens

##### Lenses

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

##### What is in a lens?

Lens makers point to 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 member, a community, or a respected organization.

##### What are tags?

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

#### Module to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

#### Definition of a lens

##### Lenses

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

##### What is in a lens?

Lens makers point to 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 member, a community, or a respected organization.

##### What are tags?

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