Summary: The systematic formulation in the previous module Minterms shows that each Boolean combination, as a union of minterms, can be designated by a vector of zero-one coefficients. A coefficient one in the ith position (numbering from zero) indicates the inclusion of minterm Mi in the union. We formulate this pattern carefully below and show how MATLAB logical operations may be utilized in problem setup and solution.
m-procedures for a pair of simple random variables
We examine, first, calculations on a pair of simple random variables X,Y, considered jointly. These are, in effect, two components of a random vectorW=(X,Y), which maps from the basic space Ω to the plane. The induced distribution is on the (t,u)-plane. Values on the horizontal axis (t-axis) correspond to values of the first coordinate random variable X and values on the vertical axis (u-axis) correspond to values of Y. We extend the computational strategy used for a single random variable.
First, let us review the one-variable strategy. In this case, data consist of values ti and corresponding probabilities P(X=ti) arranged in matrices
X=[t1,t2,⋯,tn]andPX=[P(X=t1),P(X=t2),⋯,P(X=tn)]
(1)To perform calculations on Z=g(X), we we use array operations on X to form a matrix
G=[g(t1)g(t2)⋯g(tn)]
(2)which has g(ti) in a position corresponding to P(X=ti) in matrix PX.
Basic problem. Determine P(g(X)∈M), where M is some prescribed set of values.
- Use relational operations to determine the positions for which g(ti)∈M. These will be in a zero-one matrix N, with ones in the desired positions.
- Select the P(X=ti) in the corresponding positions and sum. This is accomplished by one of the MATLAB operations to determine the inner product of N and PX
We extend these techniques and strategies to a pair of simple random variables, considered jointly.
- The data for a pair {X,Y{ of random variables are the values of X and Y, which we may put in row matricesX=[t1t2⋯tn]andY=[u1u2⋯um](3)and the joint probabilities P(X=ti,Y=uj) in a matrix P. We usually represent the distribution graphically by putting probability mass P(X=ti,Y=uj) at the point (ti,uj) on the plane. This joint probability may is represented by the matrix P with elements arranged corresponding to the mass points on the plane. ThusPhaselementP(X=ti,Y=uj)atthe(ti,uj)position(4)
- To perform calculations, we form computational matrices t and u such that — t has element ti at each (ti,uj) position (i.e., at each point on the ith column from the left) — u has element uj at each (ti,uj) position (i.e., at each point on the jth row from the bottom) MATLAB array and logical operations on t,u,P perform the specified operations on ti,uj, andP(X=ti,Y=uj) at each (ti,uj) position, in a manner analogous to the operations in the single-variable case.
- Formation of the t and u matrices is achieved by a basic setup m-procedure called jcalc. The data for this procedure are in three matrices: X=[t1,t2,⋯,tn] is the set of values for random variable X Y=[u1,u2,⋯,um] is the set of values for random variable Y, and P=[pij], where pij=P(X=ti,Y=uj). We arrange the joint probabilities as on the plane, with X-values increasing to the right and Y-values increasing upward. This is different from the usual arrangement in a matrix, in which values of the second variable increase downward. The m-procedure takes care of this inversion. The m-procedure forms the matrices t and u, utilizing the MATLAB function meshgrid, and computes the marginal distributions for X and Y. In the following example, we display the various steps utilized in the setup procedure. Ordinarily, these intermediate steps would not be displayed.
EXAMPLE 1: Setup and basic calculations
>> jdemo4 % Call for data in file jdemo4.m>> jcalc % Call for setup procedure
ix of VALUES of X X Enter row matrix of VALUEEnter JOINT PROBABILITIES (as on the plane) P Enter row mat rS of Y Y Use array operations on matrices X, Y, PX, PY, t, u, and P0.0360 0.0198 0.0297 0.0209 0.0180 0.0372 0.055>> disp(P) % Optional call for display of P 8 0.0837 0.0589 0.0744 0.0516 0.0774 0.1161 0.0817 0.1032 0.0264 0.0270 0.0405 0.0285 0.0132% Optional call for display of PY PY = 0.1356>> PX % Optional call for display of PX PX = 0.1512 0.1800 0.2700 0.1900 0.2088 >> PY 0.4300 0.3100 0.1244 - - - - - - - - - - % Steps performed by jcalc >> PX = sum(P) % Calculation of PX as performed by jcalc[t,u] = meshgrid(X,fliplr(Y)); % Formation of t, u mPX = 0.1512 0.1800 0.2700 0.1900 0.2088 >> PY = fliplr(sum(P')) % Calculation of PY (note reversal) PY = 0.1356 0.4300 0.3100 0.1244 >> atrices (note reversal) >> disp(t) % Display of calculating matrix t -3 0 1 3 5 % A row of X-values for each value of Y -3 0 1 3 51 1 1 1-3 0 1 3 5 -3 0 1 3 5 >> disp(u) % Display of calculating matrix u 2 2 2 2 2 % A column of Y-values (increasin g1 % upward) for each value of X 0 0 0 0 0Suppose we wish to determine the probability P(X2−3Y≥1). Using array operations on t and u, we obtain the matrix G=[g(ti,uj)].>> G = t.^2 - 3*u % Formation of G = [g(t_i,u_j)] matrixG = 3 -6 -5 3 19 6 -3 -2 6 22
>> M = G >= 19 0 1 9 25 15 6 7 15 31 % Positions where G >= 11 1 1 1 1M = 1 0 0 1 1 1 0 0 1 1 1 0 1 1 1 >> pM = M.*P % Selection of probabilities pM = 0.0360 0 0 0.0209 0.01800 0.0405 0.0285 0.0132 >> PM = total(pM)0.0372 0 0 0.0589 0.0744 0.0516 0 0.1161 0.0817 0.1032 0.0264 0.02 7 % Total of selected probabilities - In Example 3 from "Random Vectors and Joint Distributions" we note that the joint distribution function FXY is constant over any grid cell, including the left-hand and lower boundaries, at the value taken on at the lower left-hand corner of the cell. These lower left-hand corner values may be obtained systematically from the joint probability matrix P by a two step operation.
- Take cumulative sums upward of the columns of P.
- Take cumulative sums of the rows of the resultant matrix.
This can be done with the MATLAB function cumsum, which takes column cumulative sums downward. By flipping the matrix and transposing, we can achieve the desired results.EXAMPLE 2: Calculation of FXY values for Example 3 from "Random Vectors and Joint Distributions"
>> P = 0.1*[3 0 0; 0 6 0; 0 0 1];>> FXY = flipud(cumsum(flipud(P))) % Cumulative column sums upwardFXY = 0.3000 0.6000 0.1000 0 0.6000 0.1000Cumulative row sums FXY =0 0 0.1000 >> FXY = cumsum(FXY')' % 0.3000 0.9000 1.0000 0 0.6000 0.7000Figure 1: The joint distribution for Example 3 in "Random Vectors and Joint Distributions'. Comparison with Example 3 from "Random Vectors and Joint Distributions" shows agreement with values obtained by hand.The two step procedure has been incorprated into an m-procedure jddbn. As an example, return to the distribution in Example Example 1EXAMPLE 3: Joint distribution function for Example 1
>> jddbnEnter joint probability matrix (as on the plane) PTo view joint distribution function, call for FXY912 1.000>> disp(FXY) 0.1512 0.3312 0.6012 0. 70 0.1152 0.2754 0.5157 0.6848 0.87560.0264 0.0534 0.0939 0.1224 0.13560.0780 0.1824 0.3390 0.4492 0.5656 - As in the case of canonic for a single random variable, it is often useful to have a function version of the procedure jcalc to provide the freedom to name the outputs conveniently.function
[x,y,t,u,px,py,p] = jcalcf(X,Y,P)
The quantities x,y,t,u,px,py, and p may be given any desired names.
Joint absolutely continuous random variables
In the single-variable case, the condition that there are no point mass concentrations on the line ensures the existence of a probability density function, useful in probability calculations. A similar situation exists for a joint distribution for two (or more) variables. For any joint mapping to the plane which assigns zero probability to each set with zero area (discrete points, line or curve segments, and countable unions of these) there is a density function.
Definition
If the joint probability distribution for the pair {X,Y{ assigns zero probability to every set of points with zero area, then there exists a joint density function fXY with the property
P[(X,Y)∈Q]=∫∫QfXY
(5)We have three properties analogous to those for the single-variable case:
(f1)fXY≥0(f2)∫∫R2fXY=1(f3)FXY(t,u)=∫−∞t∫−∞ufXY
(6)At every continuity point for fXY, the density is the second partial
fXY(t,u)=
∂2FXY(t,u) |
∂t∂u |
Now
FX(t)=FXY(t,∞)=∫−∞t∫−∞∞fXY(r,s)dsdr
(8)A similar expression holds for FY(u). Use of the fundamental theorem of calculus to obtain the derivatives gives the result
fX(t)=∫−∞∞fXY(t,s)dsandfY(u)=∫−∞∞fXY(r,u)du
(9)Marginal densities. Thus, to obtain the marginal density for the first variable, integrate out the second variable in the joint density, and similarly for the marginal for the second variable.
EXAMPLE 4: Marginal density functions
fX(t)=∫fXY(t,u)du=8t∫0tudu=4t3,0≤t≤1
(10)fY(u)=∫fXY(t,u)dt=8u∫u1tdt=4u(1−u2),0≤u≤1
(11)P(0.5≤X≤0.75,Y>0.5)=P[(X,Y)∈Q] where Q is the common part of the triangle with the strip between t=0.5 and t=0.75 and above the lineu=0.5. This is the small triangle bounded by u=0.5, u=t, and t=0.75. Thus
p=8∫1/23/4∫1/2ttududt=25/256≈0.0977
(12)EXAMPLE 5: Marginal distribution with compound expression
The pair {X,Y{ has joint density fXY(t,u)=
6 |
37 |
SOLUTION
Examination of the figure shows that we have different limits for the integral with respect to u for 0≤t≤1 and for 1<t≤2.
- For 0≤t≤1fX(t)=(13)
6 37 6 37 - For 1<t≤2fX(t)=(14)
6 37 12 37
We may combine these into a single expression in a manner used extensively in subsequent treatments. Suppose M=[0,1] and N=(1,2]. Then IM(t)=1 for t∈M(i.e., 0≤t≤1) and zero elsewhere. Likewise, IN(t)=1 for t∈N and zero elsewhere. We can, therefore express fX by
fX(t)=IM(t)
(t+1)+IN(t)
t2
(15)6 |
37 |
12 |
37 |
Discrete approximation in the continuous case
For a pair {X,Y{ with joint density fXY, we approximate the distribution in a manner similar to that for a single random variable. We then utilize the techniques developed for a pair of simple random variables. If we have n approximating values ti for X and m approximating values uj for Y, we then have n·m pairs (ti,uj), corresponding to points on the plane. If we subdivide the horizontal axis for values of X, with constant increments dx, as in the single-variable case, and the vertical axis for values of Y, with constant increments dy, we have a grid structure consisting of rectangles of size dx·dy. We select ti and uj at the midpoint of its increment, so that the point (ti,uj) is at the midpoint of the rectangle. If we let the approximating pair be{X*,Y*{, we assign
pij=P((X*,Y*),=,(ti,uj))=P(X*=ti,Y*=uj)=P((X,Y)inijthrectangle)
(16)As in the one-variable case, if the increments are small enough,
P((X,Y)∈ijthrectangle)≈dx·dy·fXY(ti,uj)
(17)The m-procedure tuappr calls for endpoints of intervals which include the ranges of X and Y and for the numbers of subintervals on each. It then prompts for an expression for fXY(t,u), from which it determines the joint probability distribution. It calculates the marginal approximate distributions and sets up the calculating matrices t and u as does the m-process jcalc for simple random variables. Calculations are then carried out as for any joint simple pair.
EXAMPLE 6: Approximation to a joint continuous distribution
fXY(t,u)=3on0≤u≤t2≤1
(18)Determine P(X≤0.8,Y>0.1).
>> tuappr
Enter matrix [a b] of X-range endpoints [0 1]Enter matrix [c d] of Y-range endpoints [0 1]er number of Y approximation points 200 EnEnter number of X approximation points 200 En tter expression for joint density 3*(u <= t.^2)>> M = (t <= 0.8)&(u > 0.1); >> p = total(M.*P)Use array operations on X, Y, PX, PY, t, u, and P % Evaluation of the integral with3352455531p = 0.3355 % Maple gives 0 .
The discrete approximation may be used to obtain approximate plots of marginal distribution and density functions.
EXAMPLE 7: Approximate plots of marginal density and distribution functions
fXY(t,u)=3u on the triangle bounded by u=0, u≤1+t, and u≤1−t.
>> tuappr
Enter matrix [a b] of X-range endpoints [-1 1]Enter matrix [c d] of Y-range endpoints [0 1]er number of Y approximation points 200 EnEnter number of X approximation points 400 En tter expression for joint density 3*u.*(u<=min(1+t,1-t))PX/dx; % Density for X (seeUse array operations on X, Y, PX, PY, t, u, and P >> fx =% Theoretical (3/2)(1 - |t|)^2>> fy = PY/dy; % Density for Yunction for X (Figure 4)>> FX = cumsum(PX); % Distribution f> FY = cumsum(PY); % Distribution function for Y>>> plot(X,fx,X,FX) % Plotting details omitted
These approximation techniques useful in dealing with functions of random variables, expectations, and conditional expectation and regression.
1 comments:
Wow! That's a lot of material on random vectors. Thanks a lot!
Post a Comment