Introduction
The general mapping approach for a single random variable and the discrete alternative extends to functions of more than one variable. It is convenient to consider the case of two random variables, considered jointly. Extensions to more than two random variables are made similarly, although the details are more complicated.
The general approach extended to a pair
Consider a pair {X,Y{ having joint distribution on the plane. The approach is analogous to that for a single random variable with distribution on the line.
- To find P((X,Y)∈Q).
- Mapping approach. Simply find the amount of probability mass mapped into the set Q on the plane by the random vector W=(X,Y).
- In the absolutely continuous case, calculate ∫∫QfXY.
- In the discrete case, identify those vector values (ti,uj) of (X,Y) which are in the set Q and add the associated probabilities.
- Discrete alternative. Consider each vector value (ti,uj) of (X,Y). Select those which meet the defining conditions for Q and add the associated probabilities. This is the approach we use in the MATLAB calculations. It does not require that we describe geometrically the region Q.
- Mapping approach. Simply find the amount of probability mass mapped into the set Q on the plane by the random vector W=(X,Y).
- To find P(g(X,Y)∈M). g is real valued and M is a subset the real line.
- Mapping approach. Determine the set Q of all those (t,u) which are mapped into M by the function g. NowW(ω)=(X(ω),Y(ω))∈Qiffg((X(ω),Y(ω))∈MHence(1){ω:g(X(ω),Y(ω))∈M{={ω:(X(ω),Y(ω))∈Q{(2)Since these are the same event, they must have the same probability. Once Q is identified on the plane, determine P((X,Y)∈Q) in the usual manner (see part a, above).
- Discrete alternative. For each possible vector value (ti,uj) of (X,Y), determine whether g(ti,uj) meets the defining condition for M. Select those (ti,uj) which do and add the associated probabilities.
- Mapping approach. Determine the set Q of all those (t,u) which are mapped into M by the function g. Now
We illustrate the mapping approach in the absolutely continuous case. A key element in the approach is finding the set Q on the plane such that g(X,Y)∈M iff (X,Y)∈Q. The desired probability is obtained by integrating fXY over Q.
EXAMPLE 1: A numerical example
The pair {X,Y{ has joint density fXY(t,u)=
6 |
37 |
P(Y≤X)=∫02∫0t
(t+2u)dudt=32/37≈0.8649(3)
6 |
37 |
EXAMPLE 2: The density for the sum X+Y
Suppose the pair {X,Y{ has joint density fXY. Determine the density for
Z=X+Y(4)
SOLUTION
FZ(v)=P(X+Y≤v)=P((X,Y)∈Qv)whereQv={(t,u):t+u≤v{={(t,u):u≤v−t{(5)
For any fixed v, the region Qv is the portion of the plane on or below the line u=v−t (see Figure 2). Thus
FZ(v)=∫∫QvfXY=∫−∞∞∫−∞v−tfXY(t,u)dudt(6)
Differentiating with the aid of the fundamental theorem of calculus, we get
fZ(v)=∫∞∞fXY(t,v−t)dt(7)
This integral expresssion is known as a convolution integral.
EXAMPLE 3: Sum of joint uniform random variables
Suppose the pair {X,Y{ has joint uniform density on the unit square 0≤t≤1, 0≤u≤1. Determine the density for Z=X+Y.
SOLUTION
FZ(v) is the probability in the region Qv:u≤v−t. Now PXY(Qv)=1−PXY(Qvc), where the complementary set Qvc is the set of points above the line. As Figure 3 shows, for v≤1, the part of Qv which has probability mass is the lower shaded triangular region on the figure, which has area (and hence probability) v2/2. For v>1, the complementary region Qvc is the upper shaded region. It has area (2−v)2/2. so that in this case,
PXY(Qv)=1−(2−v)2/2. Thus,
FZ(v)=
for0≤v≤1andFZ(v)=1−
for1≤v≤2(8)
v2 |
2 |
(2−v)2 |
2 |
Differentiation shows that Z has the symmetric triangular distribution on [0,2], since
fZ(v)=vfor0≤v≤1andfZ(v)=(2−v)for1≤v≤2(9)
With the use of indicator functions, these may be combined into a single expression
fZ(v)=I[0,1](v)v+I(1,2](v)(2−v)(10)
ALTERNATE SOLUTION
Since fXY(t,u)=I[0,1](t)I[0,1](u), we have fXY(t,v−t)=I[0,1](t)I[0,1](v−t). Now 0≤v−t≤1 iff v−1≤t≤v, so that
fXY(t,v−t)=I[0,1](v)I[0,v](t)+I(1,2](v)I[v−1,1](t)(11)
Integration with respect to t gives the result above.
Independence of functions of independent random variables
Suppose {X,Y{ is an independent pair. Let Z=g(X),W=h(Y). Since
Z−1(M)=X−1[g−1(M)]andW−1(N)=Y−1[h−1(N)(12)
the pair {Z−1(M),W−1(N){ is independent for each pair {M,N{. Thus, the pair {Z,W{ is independent.
If {X,Y{ is an independent pair and Z=g(X),W=h(Y), then the pair {Z,W{ is independent. However, if Z=g(X,Y) and W=h(X,Y), then in general {Z,W{ is not independent. This is illustrated for simple random variables with the aid of the m-procedure jointzw at the end of the next section.
EXAMPLE 4: Independence of simple approximations to an independent pair
Suppose {X,Y{ is an independent pair with simple approximations Xs and Ys as described in Distribution Approximations.
Xs=
tiIEi=
tiIMi(X)andYs=
ujIFj=
ujINj(Y)(13)
n |
∑ |
i=1 |
n |
∑ |
i=1 |
m |
∑ |
j=1 |
m |
∑ |
j=1 |
As functions of X and Y, respectively, the pair {Xs,Ys{ is independent. Also each pair {IMi(X),INj(Y){ is independent.
Use of MATLAB on pairs of simple random variables
In the single-variable case, we use array operations on the values of X to determine a matrix of values of g(X). In the two-variable case, we must use array operations on the calculating matrices t and u to obtain a matrix G whose elements are g(ti,uj). To obtain the distribution for Z=g(X,Y), we may use the m-function csort on G and the joint probability matrix P. A first step, then, is the use of jcalc or icalc to set up the joint distribution and the calculating matrices. This is illustrated in the following example.
EXAMPLE 5
% file jdemo3.m
% data for joint simple distribution
X = [-4 -2 0 1 3];
Y = [0 1 2 4];
P = [0.0132 0.0198 0.0297 0.0209 0.0264;
0.0372 0.0558 0.0837 0.0589 0.0744;
0.0516 0.0774 0.1161 0.0817 0.1032;
0.0180 0.0270 0.0405 0.0285 0.0360];
jdemo3 % Call for data
jcalc % Set up of calculating matrices t, u.
Enter JOINT PROBABILITIES (as on the plane) P
Enter row matrix of VALUES of X X
Enter row matrix of VALUES of Y Y
Use array operations on matrices X, Y, PX, PY, t, u, and P
G = t.^2 -3*u; % Formation of G = [g(ti,uj)]
M = G >= 1; % Calculation using the XY distribution
PM = total(M.*P) % Alternately, use total((G>=1).*P)
PM = 0.4665
[Z,PZ] = csort(G,P);
PM = (Z>=1)*PZ' % Calculation using the Z distribution
PM = 0.4665
disp([Z;PZ]') % Display of the Z distribution
-12.0000 0.0297
-11.0000 0.0209
-8.0000 0.0198
-6.0000 0.0837
-5.0000 0.0589
-3.0000 0.1425
-2.0000 0.1375
0 0.0405
1.0000 0.1059
3.0000 0.0744
4.0000 0.0402
6.0000 0.1032
9.0000 0.0360
10.0000 0.0372
13.0000 0.0516
16.0000 0.0180
We extend the example above by considering a function W=h(X,Y) which has a composite definition.
EXAMPLE 6: Continuation of Example 5
Let
W={
DeterminethedistributionforW(14)
X | forX+Y≥1 |
X2+Y2 | forX+Y<1 |
H = t.*(t+u>=1) + (t.^2 + u.^2).*(t+u<1); % Specification of h(t,u)
[W,PW] = csort(H,P); % Distribution for W = h(X,Y)
disp([W;PW]')
-2.0000 0.0198
0 0.2700
1.0000 0.1900
3.0000 0.2400
4.0000 0.0270
5.0000 0.0774
8.0000 0.0558
16.0000 0.0180
17.0000 0.0516
20.0000 0.0372
32.0000 0.0132
ddbn % Plot of distribution function
Enter row matrix of values W
Enter row matrix of probabilities PW
print % See Figure 4
Joint distributions for two functions of (X,Y)
In previous treatments, we use csort to obtain the marginal distribution for a single function Z=g(X,Y). It is often desirable to have the joint distribution for a pair Z=g(X,Y) andW=h(X,Y). As special cases, we may have Z=X or W=Y. Suppose
Zhasvalues[z1z2⋯zc]andWhasvalues[w1w2⋯wr](15)
The joint distribution requires the probability of each pair, P(W=wi,Z=zj). Each such pair of values corresponds to a set of pairs of X and Y values. To determine the joint probability matrixPZW for (Z,W) arranged as on the plane, we assign to each position (i,j) the probability P(W=wi,Z=zj), with values of W increasing upward. Each pair of (W,Z) values corresponds to one or more pairs of (Y,X) values. If we select and add the probabilities corresponding to the latter pairs, we have P(W=wi,Z=zj). This may be accomplished as follows:
- Set up calculation matrices t and u as with jcalc.
- Use array arithmetic to determine the matrices of values G=[g(t,u)] and H=[h(t,u)].
- Use csort to determine the Z and W value matrices and the PZ and PW marginal probability matrices.
- For each pair (wi,zj), use the MATLAB function find to determine the positions a for which(H==W(i))&(G==Z(j))(16)
- Assign to the (i,j) position in the joint probability matrix PZW for (Z,W) the probabilityPZW(i,j)=total(P(a))(17)
We first examine the basic calculations, which are then implemented in the m-procedure jointzw.
EXAMPLE 7: Illustration of the basic joint calculations
% file jdemo7.m
P = [0.061 0.030 0.060 0.027 0.009;
0.015 0.001 0.048 0.058 0.013;
0.040 0.054 0.012 0.004 0.013;
0.032 0.029 0.026 0.023 0.039;
0.058 0.040 0.061 0.053 0.018;
0.050 0.052 0.060 0.001 0.013];
X = -2:2;
Y = -2:3;
jdemo7 % Call for data in jdemo7.m
jcalc % Used to set up calculation matrices t, u
- - - - - - - - - -
H = u.^2 % Matrix of values for W = h(X,Y)
H =
9 9 9 9 9
4 4 4 4 4
1 1 1 1 1
0 0 0 0 0
1 1 1 1 1
4 4 4 4 4
G = abs(t) % Matrix of values for Z = g(X,Y)
G =
2 1 0 1 2
2 1 0 1 2
2 1 0 1 2
2 1 0 1 2
2 1 0 1 2
2 1 0 1 2
[W,PW] = csort(H,P) % Determination of marginal for W
W = 0 1 4 9
PW = 0.1490 0.3530 0.3110 0.1870
[Z,PZ] = csort(G,P) % Determination of marginal for Z
Z = 0 1 2
PZ = 0.2670 0.3720 0.3610
r = W(3) % Third value for W
r = 4
s = Z(2) % Second value for Z
s = 1
To determine P(W=4,Z=1), we need to determine the (t,u) positions for which this pair of (W,Z) values is taken on. By inspection, we find these to be (2,2), (6,2), (2,4), and (6,4). Then P(W=4,Z=1) is the total probability at these positions. This is 0.001 + 0.052 + 0.058 + 0.001 = 0.112. We put this probability in the joint probability matrix PZW at the W=4,Z=1 position. This may be achieved by MATLAB with the following operations.
[i,j] = find((H==W(3))&(G==Z(2))); % Location of (t,u) positions
disp([i j]) % Optional display of positions
2 2
6 2
2 4
6 4
a = find((H==W(3))&(G==Z(2))); % Location in more convenient form
P0 = zeros(size(P)); % Setup of zero matrix
P0(a) = P(a) % Display of designated probabilities in P
P0 =
0 0 0 0 0
0 0.0010 0 0.0580 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0.0520 0 0.0010 0
PZW = zeros(length(W),length(Z)) % Initialization of PZW matrix
PZW(3,2) = total(P(a)) % Assignment to PZW matrix with
PZW = 0 0 0 % W increasing downward
0 0 0
0 0.1120 0
0 0 0
PZW = flipud(PZW) % Assignment with W increasing upward
PZW =
0 0 0
0 0.1120 0
0 0 0
0 0 0
The procedure jointzw carries out this operation for each possible pair of W and Z values (with the
flipud
operation coming only after all individual assignments are made).EXAMPLE 8: Joint distribution for Z=g(X,Y)=||X|−Y| and W=h(X,Y)=|XY|
% file jdemo3.m data for joint simple distribution
X = [-4 -2 0 1 3];
Y = [0 1 2 4];
P = [0.0132 0.0198 0.0297 0.0209 0.0264;
0.0372 0.0558 0.0837 0.0589 0.0744;
0.0516 0.0774 0.1161 0.0817 0.1032;
0.0180 0.0270 0.0405 0.0285 0.0360];
jdemo3 % Call for data
jointzw % Call for m-program
Enter joint prob for (X,Y): P
Enter values for X: X
Enter values for Y: Y
Enter expression for g(t,u): abs(abs(t)-u)
Enter expression for h(t,u): abs(t.*u)
Use array operations on Z, W, PZ, PW, v, w, PZW
disp(PZW)
0.0132 0 0 0 0
0 0.0264 0 0 0
0 0 0.0570 0 0
0 0.0744 0 0 0
0.0558 0 0 0.0725 0
0 0 0.1032 0 0
0 0.1363 0 0 0
0.0817 0 0 0 0
0.0405 0.1446 0.1107 0.0360 0.0477
EZ = total(v.*PZW)
EZ = 1.4398
ez = Z*PZ' % Alternate, using marginal dbn
ez = 1.4398
EW = total(w.*PZW)
EW = 2.6075
ew = W*PW' % Alternate, using marginal dbn
ew = 2.6075
M = v > w; % P(Z>W)
PM = total(M.*PZW)
PM = 0.3390
At noted in the previous section, if {X,Y{ is an independent pair and Z=g(X),
W=h(Y), then the pair {Z,W{ is independent. However, if Z=g(X,Y) and
W=h(X,Y), then in general the pair {Z,W{ is not independent. We may illustrate this with the aid of the m-procedure jointzw
EXAMPLE 9: Functions of independent random variables
jdemo3
itest
Enter matrix of joint probabilities P
The pair {X,Y} is independent % The pair {X,Y} is independent
jointzw
Enter joint prob for (X,Y): P
Enter values for X: X
Enter values for Y: Y
Enter expression for g(t,u): t.^2 - 3*t % Z = g(X)
Enter expression for h(t,u): abs(u) + 3 % W = h(Y)
Use array operations on Z, W, PZ, PW, v, w, PZW
itest
Enter matrix of joint probabilities PZW
The pair {X,Y} is independent % The pair {g(X),h(Y)} is independent
jdemo3 % Refresh data
jointzw
Enter joint prob for (X,Y): P
Enter values for X: X
Enter values for Y: Y
Enter expression for g(t,u): t+u % Z = g(X,Y)
Enter expression for h(t,u): t.*u % W = h(X,Y)
Use array operations on Z, W, PZ, PW, v, w, PZW
itest
Enter matrix of joint probabilities PZW
The pair {X,Y} is NOT independent % The pair {g(X,Y),h(X,Y)} is not indep
To see where the product rule fails, call for D % Fails for all pairs
Absolutely continuous case: analysis and approximation
As in the analysis Joint Distributions, we may set up a simple approximation to the joint distribution and proceed as for simple random variables. In this section, we solve several examples analytically, then obtain simple approximations.
EXAMPLE 10: Distribution for a product
Suppose the pair {X,Y{ has joint density fXY. Let Z=XY. Determine Qv such that P(Z≤v)=P((X,Y),∈,Qv).
SOLUTION (see Figure 5)
Qv={(t,u):tu≤v{={(t,u):t>0,u≤v/t{⋁{(t,u):t<0,u≥v/t{{(18)
EXAMPLE 11
{X,Y{∼ uniform on unit square
fXY(t,u)=1,0≤t≤1,0≤u≤1. Then (see Figure 6)
P(XY≤v)=∫∫Qv1dudtwhereQv={(t,u):0≤t≤1,0≤u≤min{1,v/t{{(19)
Integration shows
FZ(v)=P(XY≤v)=v(1,−,ln,(,v,))sothatfZ(v)=−ln(v)=ln(1/v),0<v≤1(20)
For v=0.5,FZ(0.5)=0.8466.
% Note that although f = 1, it must be expressed in terms of t, u.
tuappr
Enter matrix [a b] of X-range endpoints [0 1]
Enter matrix [c d] of Y-range endpoints [0 1]
Enter number of X approximation points 200
Enter number of Y approximation points 200
Enter expression for joint density (u>=0)&(t>=0)
Use array operations on X, Y, PX, PY, t, u, and P
G = t.*u;
[Z,PZ] = csort(G,P);
p = (Z<=0.5)*PZ'
p = 0.8465 % Theoretical value 0.8466, above
EXAMPLE 12: Continuation of Example 5 from "Random Vectors and Joint Distributions"
The pair {X,Y{ has joint density fXY(t,u)=
6 |
37 |
ANALYTIC SOLUTION
P(Z≤1)=P((,X,,,,Y,),∈,Q)whereQ={(t,u):u≤1/t{(21)
Reference to Figure 7 shows that
P((,X,,,,Y,),∈,Q)=
∫01∫01(t+2u)dudt+
∫12∫01/t(t+2u)dudt=9/37+9/37=18/37≈0.4865(22)
6 |
37 |
6 |
37 |
APPROXIMATE SOLUTION
tuappr
Enter matrix [a b] of X-range endpoints [0 2]
Enter matrix [c d] of Y-range endpoints [0 2]
Enter number of X approximation points 300
Enter number of Y approximation points 300
Enter expression for joint density (6/37)*(t + 2*u).*(u<=max(t,1))
Use array operations on X, Y, PX, PY, t, u, and P
Q = t.*u<=1;
PQ = total(Q.*P)
PQ = 0.4853 % Theoretical value 0.4865, above
G = t.*u; % Alternate, using the distribution for Z
[Z,PZ] = csort(G,P);
PZ1 = (Z<=1)*PZ'
PZ1 = 0.4853
In the following example, the function g has a compound definition. That is, it has a different rule for different parts of the plane.
EXAMPLE 13: A compound function
The pair {X,Y{ has joint density fXY(t,u)=
2 |
3 |
Z={
=IQ(X,Y)Y+IQc(X,Y)(X+Y)(23)
Y | forX2−Y≥0 |
X+Y | forX2−Y<0 |
for Q={(t,u):u≤t2{. Determine P(Z<=0.5).
ANALYTICAL SOLUTION
P(Z≤1/2)=P(Y≤1/2,Y≤X2)+P(X+Y≤1/2,Y>X2)=P((X,Y),∈,,QA,⋁,QB)(24)
where QA={(t,u):u≤1/2,u≤t2{ and QB={(t,u):t+u≤1/2,u>t2{. Reference to Figure 8 shows that this is the part of the unit square for whichu≤min(max(1/2−t,t2),1/2). We may break up the integral into three parts. Let 1/2−t1=t12 and t22=1/2. Then
P(Z≤1/2)=
∫0t1∫01/2−t(t+2u)dudt+
∫t1t2∫0t2(t+2u)dudt+
∫t21∫01/2(t+2u)dudt=0.2322(25)
2 |
3 |
2 |
3 |
2 |
3 |
APPROXIMATE SOLUTION
tuappr
Enter matrix [a b] of X-range endpoints [0 1]
Enter matrix [c d] of Y-range endpoints [0 1]
Enter number of X approximation points 200
Enter number of Y approximation points 200
Enter expression for joint density (2/3)*(t + 2*u)
Use array operations on X, Y, PX, PY, t, u, and P
Q = u <= t.^2;
G = u.*Q + (t + u).*(1-Q);
prob = total((G<=1/2).*P)
prob = 0.2328 % Theoretical is 0.2322, above
The setup of the integrals involves careful attention to the geometry of the system. Once set up, the evaluation is elementary but tedious. On the other hand, the approximation proceeds in a straightforward manner from the normal description of the problem. The numerical result compares quite closely with the theoretical value and accuracy could be improved by taking more subdivision points.
0 comments:
Post a Comment