Skip to main content
Chemistry LibreTexts

Untitled Page 13

  • Page ID
    125286
  • Chapter 8Random Vectors and joint Distributions

    8.1Random Vectors and Joint Distributions*

    Introduction

    A single, real-valued random variable is a function (mapping) from the basic space Ω to the real line. That is, to each possible outcome ω of an experiment there corresponds a real value t=X(ω). The mapping induces a probability mass distribution on the real line, which provides a means of making probability calculations. The distribution is described by a distribution function FX. In the absolutely continuous case, with no point mass concentrations, the distribution may also be described by a probability density function fX. The probability density is the linear density of the probability mass along the real line (i.e., mass per unit length). The density is thus the derivative of the distribution function. For a simple random variable, the probability distribution consists of a point mass pi at each possible value ti of the random variable. Various m-procedures and m-functions aid calculations for simple distributions. In the absolutely continuous case, a simple approximation may be set up, so that calculations for the random variable are approximated by calculations on this simple distribution.

    Often we have more than one random variable. Each can be considered separately, but usually they have some probabilistic ties which must be taken into account when they are considered jointly. We treat the joint case by considering the individual random variables as coordinates of a random vector. We extend the techniques for a single random variable to the multidimensional case. To simplify exposition and to keep calculations manageable, we consider a pair of random variables as coordinates of a two-dimensional random vector. The concepts and results extend directly to any finite number of random variables considered jointly.

    Random variables considered jointly; random vectors

    As a starting point, consider a simple example in which the probabilistic interaction between two random quantities is evident.

    Example 8.1A selection problem

    Two campus jobs are open. Two juniors and three seniors apply. They seem equally qualified, so it is decided to select them by chance. Each combination of two is equally likely. Let X be the number of juniors selected (possible values 0, 1, 2) and Y be the number of seniors selected (possible values 0, 1, 2). However there are only three possible pairs of values for _autogen-svg2png-0002.png, or _autogen-svg2png-0003.png. Others have zero probability, since they are impossible. Determine the probability for each of the possible pairs.

    SOLUTION

    There are _autogen-svg2png-0004.png equally likely pairs. Only one pair can be both juniors. Six pairs can be one of each. There are _autogen-svg2png-0005.png ways to select pairs of seniors. Thus

    (8.1)
    _autogen-svg2png-0006.png

    These probabilities add to one, as they must, since this exhausts the mutually exclusive possibilities. The probability of any other combination must be zero. We also have the distributions for the random variables conisidered individually.

    (8.2)
    _autogen-svg2png-0007.png

    We thus have a joint distribution and two individual or marginal distributions.

    We formalize as follows:

    A pair _autogen-svg2png-0008.png of random variables considered jointly is treated as the pair of coordinate functions for a two-dimensional random vector _autogen-svg2png-0009.png. To each ωΩ, W assigns the pair of real numbers _autogen-svg2png-0011.png, where X(ω)=t and Y(ω)=u. If we represent the pair of values _autogen-svg2png-0014.png as the point _autogen-svg2png-0015.png on the plane, then _autogen-svg2png-0016.png, so that

    (8.3)
    _autogen-svg2png-0017.png

    is a mapping from the basic space Ω to the plane R2. Since W is a function, all mapping ideas extend. The inverse mapping W–1 plays a role analogous to that of the inverse mapping X–1 for a real random variable. A two-dimensional vector W is a random vector iff W–1(Q) is an event for each reasonable set (technically, each Borel set) on the plane.

    A fundamental result from measure theory ensures

    _autogen-svg2png-0021.png is a random vector iff each of the coordinate functions X and Y is a random variable.

    In the selection example above, we model _autogen-svg2png-0022.png (the number of juniors selected)   and Y (the number of seniors selected) as random variables. Hence the vector-valued function

    Induced distribution and the joint distribution function

    In a manner parallel to that for the single-variable case, we obtain a mapping of probability mass from the basic space to the plane. Since W–1(Q) is an event for each reasonable set Q on the plane, we may assign to Q the probability mass

    (8.4)
    _autogen-svg2png-0024.png

    Because of the preservation of set operations by inverse mappings as in the single-variable case, the mass assignment determines PXY as a probability measure on the subsets of the plane R2. The argument parallels that for the single-variable case. The result is the probability distribution induced by _autogen-svg2png-0026.png. To determine the probability that the vector-valued function _autogen-svg2png-0027.png takes on a (vector) value in region Q, we simply determine how much induced probability mass is in that region.

    Example 8.2Induced distribution and probability calculations

    To determine _autogen-svg2png-0028.png, we determine the region for which the first coordinate value (which we call t) is between one and three and the second coordinate value (which we call u) is greater than zero. This corresponds to the set Q of points on the plane with 1≤t≤3 and u>0. Gometrically, this is the strip on the plane bounded by (but not including) the horizontal axis and by the vertical lines t=1 and t=3 (included). The problem is to determine how much probability mass lies in that strip. How this is acheived depends upon the nature of the distribution and how it is described.

    As in the single-variable case, we have a distribution function.

    Definition

    The joint distribution function FXY for _autogen-svg2png-0034.png is given by

    (8.5)
    _autogen-svg2png-0035.png

    This means that _autogen-svg2png-0036.png is equal to the probability mass in the region Qtu on the plane such that the first coordinate is less than or equal to t and the second coordinate is less than or equal to u. Formally, we may write

    (8.6)
    _autogen-svg2png-0038.png

    Now for a given point (a,b), the region Qab is the set of points (t,u) on the plane which are on or to the left of the vertical line through (t,0)and on or below the horizontal line through (0,u) (see Figure 1 for specific point t=a,u=b). We refer to such regions as semiinfinite intervals on the plane.

    The theoretical result quoted in the real variable case extends to ensure that a distribution on the plane is determined uniquely by consistent assignments to the semiinfinite intervals Qtu. Thus, the induced distribution is determined completely by the joint distribution function.

    fig8_2_1.png
    Figure 8.1
    The region Qab for the value FXY(a,b).

    Distribution function for a discrete random vector

    The induced distribution consists of point masses. At point _autogen-svg2png-0048.png in the range of _autogen-svg2png-0049.png there is probability mass _autogen-svg2png-0050.png. As in the general case, to determine _autogen-svg2png-0051.png we determine how much probability mass is in the region. In the discrete case (or in any case where there are point mass concentrations) one must be careful to note whether or not the boundaries are included in the region, should there be mass concentrations on the boundary.

    fig8_2_2.png
    Figure 8.2
    The joint distribution for Example 8.3.
    Example 8.3Distribution function for the selection problem in Example 8.1

    The probability distribution is quite simple. Mass 3/10 at (0,2), 6/10 at (1,1), and 1/10 at (2,0). This distribution is plotted in Figure 8.2. To determine (and visualize) the joint distribution function, think of moving the point _autogen-svg2png-0052.png on the plane. The region Qtu is a giant “sheet” with corner at _autogen-svg2png-0054.png. The value of _autogen-svg2png-0055.png is the amount of probability covered by the sheet. This value is constant over any grid cell, including the left-hand and lower boundariies, and is the value taken on at the lower left-hand corner of the cell. Thus, if _autogen-svg2png-0056.png is in any of the three squares on the lower left hand part of the diagram, no probability mass is covered by the sheet with corner in the cell. If _autogen-svg2png-0057.png is on or in the square having probability 6/10 at the lower left-hand corner, then the sheet covers that probability, and the value of _autogen-svg2png-0058.png. The situation in the other cells may be checked out by this procedure.

    Distribution function for a mixed distribution

    Example 8.4A mixed distribution

    The pair _autogen-svg2png-0059.png produces a mixed distribution as follows (see Figure 8.3)

    Point masses 1/10 at points (0,0), (1,0), (1,1), (0,1)

    Mass 6/10 spread uniformly over the unit square with these vertices

    The joint distribution function is zero in the second, third, and fourth quadrants.

    • If the point _autogen-svg2png-0060.png is in the square or on the left and lower boundaries, the sheet covers the point mass at (0,0) plus 0.6 times the area covered within the square. Thus in this region

      (8.7)
      _autogen-svg2png-0061.png
    • If the pont _autogen-svg2png-0062.png is above the square (including its upper boundary) but to the left of the line t=1, the sheet covers two point masses plus the portion of the mass in the square to the left of the vertical line through _autogen-svg2png-0064.png. In this case

      (8.8)
      _autogen-svg2png-0065.png
    • If the point _autogen-svg2png-0066.png is to the right of the square (including its boundary) with 0≤u<1, the sheet covers two point masses and the portion of the mass in the square below the horizontal line through _autogen-svg2png-0068.png, to give

      (8.9)
      _autogen-svg2png-0069.png
    • If _autogen-svg2png-0070.png is above and to the right of the square (i.e., both 1≤t and 1≤u). then all probability mass is covered and _autogen-svg2png-0073.png in this region.

    fig8_2_3.png
    Figure 8.3
    Mixed joint distribution for Example 8.4.

    Marginal distributions

    If the joint distribution for a random vector is known, then the distribution for each of the component random variables may be determined. These are known as marginal distributions. In general, the converse is not true. However, if the component random variables form an independent pair, the treatment in that case shows that the marginals determine the joint distribution.

    To begin the investigation, note that

    (8.10)
    _autogen-svg2png-0074.png

    Thus

    (8.11)
    _autogen-svg2png-0075.png

    This may be interpreted with the aid of Figure 8.4. Consider the sheet for point _autogen-svg2png-0076.png.

    fig8_3_1.png
    Figure 8.4
    Construction for obtaining the marginal distribution for X.

    If we push the point up vertically, the upper boundary of Qtu is pushed up until eventually all probability mass on or to the left of the vertical line through _autogen-svg2png-0078.png is included. This is the total probability that Xt. Now FX(t) describes probability mass on the line. The probability mass described by FX(t) is the same as the total joint probability mass on or to the left of the vertical line through _autogen-svg2png-0082.png. We may think of the mass in the half plane being projected onto the horizontal line to give the marginal distribution for X. A parallel argument holds for the marginal for Y.

    (8.12)
    _autogen-svg2png-0083.png

    This mass is projected onto the vertical axis to give the marginal distribution for Y.

    Marginals for a joint discrete distribution

    Consider a joint simple distribution.

    (8.13)
    _autogen-svg2png-0084.png

    Thus, all the probability mass on the vertical line through _autogen-svg2png-0085.png is projected onto the point ti on a horizontal line to give _autogen-svg2png-0086.png. Similarly, all the probability mass on a horizontal line through _autogen-svg2png-0087.png is projected onto the point uj on a vertical line to give _autogen-svg2png-0088.png.

    Example 8.5Marginals for a discrete distribution

    The pair _autogen-svg2png-0089.png produces a joint distribution that places mass 2/10 at each of the five points

    _autogen-svg2png-0090.png (See Figure 8.5)

    The marginal distribution for X has masses 2/10, 2/10, 4/10, 2/10 at points t=0,1,2,3, respectively. Similarly, the marginal distribution for Y has masses 4/10, 4/10, 2/10 at points u=0,1,2, respectively.

    fig8_3_2.png
    Figure 8.5
    Marginal distribution for Example 1.
    Example 8.6

    Consider again the joint distribution in Example 8.4. The pair _autogen-svg2png-0093.png produces a mixed distribution as follows:

    Point masses 1/10 at points (0,0), (1,0), (1,1), (0,1)

    Mass 6/10 spread uniformly over the unit square with these vertices

    The construction in Figure 8.6 shows the graph of the marginal distribution function FX. There is a jump in the amount of 0.2 at t=0, corresponding to the two point masses on the vertical line. Then the mass increases linearly with t, slope 0.6, until a final jump at t=1 in the amount of 0.2 produced by the two point masses on the vertical line. At t=1, the total mass is “covered” and FX(t) is constant at one for t≥1. By symmetry, the marginal distribution for Y is the same.

    fig8_3_3.png
    Figure 8.6
    Marginal distribution for Example 8.6.

    8.2Random Vectors and MATLAB*

    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 vector _autogen-svg2png-0002.png, which maps from the basic space Ω to the plane. The induced distribution is on the _autogen-svg2png-0003.png-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 _autogen-svg2png-0004.png arranged in matrices

    (8.14)
    _autogen-svg2png-0005.png

    To perform calculations on Z=g(X), we we use array operations on X to form a matrix

    (8.15)
    _autogen-svg2png-0007.png

    which has _autogen-svg2png-0008.png in a position corresponding to _autogen-svg2png-0009.png 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 _autogen-svg2png-0012.png. These will be in a zero-one matrix N, with ones in the desired positions.

    • Select the _autogen-svg2png-0013.png 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.

    1. The data for a pair {X,Y} of random variables are the values of X and Y, which we may put in row matrices

      (8.16)
      _autogen-svg2png-0016.png

      and the joint probabilities _autogen-svg2png-0017.png in a matrix P. We usually represent the distribution graphically by putting probability mass _autogen-svg2png-0018.png at the point _autogen-svg2png-0019.png on the plane. This joint probability may is represented by the matrix P with elements arranged corresponding to the mass points on the plane. Thus

      (8.17)
      _autogen-svg2png-0020.png
    2. To perform calculations, we form computational matrices t and u such that — t has element ti at each _autogen-svg2png-0021.png position (i.e., at each point on the ith column from the left) — u has element uj at each _autogen-svg2png-0022.png 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, and _autogen-svg2png-0025.png at each _autogen-svg2png-0026.png position, in a manner analogous to the operations in the single-variable case.

    3. 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: _autogen-svg2png-0027.png is the set of values for random variable X _autogen-svg2png-0028.png is the set of values for random variable Y, and _autogen-svg2png-0029.png, where _autogen-svg2png-0030.png. 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 8.7Setup and basic calculations

      >> jdemo4                         % Call for data in file jdemo4.m
      >> jcalc                          % Call for setup procedure
      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
      >> disp(P)                        % Optional call for display of P
          0.0360    0.0198    0.0297    0.0209    0.0180
          0.0372    0.0558    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
      >> PX                             % Optional call for display of PX
      PX =  0.1512    0.1800    0.2700    0.1900    0.2088
      >> PY                             % Optional call for display of PY
      PY =  0.1356    0.4300    0.3100    0.1244
      - - - - - - - - - -               % Steps performed by jcalc
      >> PX = sum(P)                    % Calculation of PX as performed by jcalc
      PX =  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
      >> [t,u] = meshgrid(X,fliplr(Y)); % Formation of t, u matrices (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     5
          -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 (increasing
           1     1     1     1     1    % upward) for each value of X
           0     0     0     0     0
          -2    -2    -2    -2    -2
      

      Suppose we wish to determine the probability _autogen-svg2png-0031.png. Using array operations on t and u, we obtain the matrix _autogen-svg2png-0032.png.

      >> G = t.^2 - 3*u                 % Formation of G = [g(t_i,u_j)] matrix
      G  = 3    -6    -5     3    19
           6    -3    -2     6    22
           9     0     1     9    25
          15     6     7    15    31
      >> M = G >=  1                    % Positions where G >= 1
      M =  1     0     0     1     1
           1     0     0     1     1
           1     0     1     1     1
           1     1     1     1     1
      >> pM = M.*P                    % Selection of probabilities
      pM =
          0.0360         0         0    0.0209    0.0180
          0.0372         0         0    0.0589    0.0744
          0.0516         0    0.1161    0.0817    0.1032
          0.0264    0.0270    0.0405    0.0285    0.0132
      >> PM = total(pM)               % Total of selected probabilities
      PM =  0.7336                    % P(g(X,Y) >= 1)
      

    4. 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 8.8Calculation 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 upward
      FXY =
          0.3000    0.6000    0.1000
               0    0.6000    0.1000
               0         0    0.1000
      >> FXY = cumsum(FXY')'              % Cumulative row sums
      FXY =
          0.3000    0.9000    1.0000
               0    0.6000    0.7000
               0         0    0.1000
      

      fig8_2_2.png
      Figure 8.7
      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 8.7

      Example 8.9Joint distribution function for Example 8.7
      >> jddbn
      Enter joint probability matrix (as on the plane)  P
      To view joint distribution function, call for FXY
      >> disp(FXY)
          0.1512    0.3312    0.6012    0.7912    1.0000
          0.1152    0.2754    0.5157    0.6848    0.8756
          0.0780    0.1824    0.3390    0.4492    0.5656
          0.0264    0.0534    0.0939    0.1224    0.1356
      

      These values may be put on a grid, in the same manner as in Figure 2 for Example 3 in "Random Vectors and Joint Distributions".

    5. 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

    (8.18)
    _autogen-svg2png-0038.png

    We have three properties analogous to those for the single-variable case:

    (8.19)
    _autogen-svg2png-0039.png

    At every continuity point for fXY, the density is the second partial

    (8.20)
    _autogen-svg2png-0041.png

    Now

    (8.21)
    _autogen-svg2png-0042.png

    A similar expression holds for FY(u). Use of the fundamental theorem of calculus to obtain the derivatives gives the result

    (8.22)
    _autogen-svg2png-0044.png

    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 8.10Marginal density functions

    Let _autogen-svg2png-0045.png. This region is the triangle bounded by u=0, u=t, and t=1 (see Figure 8.8)

    (8.23)
    _autogen-svg2png-0049.png
    (8.24)
    _autogen-svg2png-0050.png

    _autogen-svg2png-0051.png where Q is the common part of the triangle with the strip between t=0.5 and t=0.75 and above the line u=0.5. This is the small triangle bounded by u=0.5, u=t, and t=0.75. Thus

    (8.25)
    _autogen-svg2png-0058.png
    fig8_5_1.png
    Figure 8.8
    Distribution for Example 8.10.
    Example 8.11Marginal distribution with compound expression

    The pair _autogen-svg2png-0059.png has joint density _autogen-svg2png-0060.png on the region bounded by t=0, t=2, u=0, and _autogen-svg2png-0064.png (see Figure 8.9). Determine the marginal density fX.

    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≤1

      (8.26)
      _autogen-svg2png-0068.png
    • For 1<t≤2

      (8.27)
      _autogen-svg2png-0070.png

    We may combine these into a single expression in a manner used extensively in subsequent treatments. Suppose _autogen-svg2png-0071.png and _autogen-svg2png-0072.png. Then IM(t)=1 for tM (i.e., 0≤t≤1) and zero elsewhere. Likewise, IN(t)=1 for tN and zero elsewhere. We can, therefore express fX by

    (8.28)
    _autogen-svg2png-0078.png
    fig8_5_2.png
    Figure 8.9
    Marginal distribution for Example 8.11.

    Discrete approximation in the continuous case

    For a pair _autogen-svg2png-0079.png 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 _autogen-svg2png-0082.png, 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 _autogen-svg2png-0086.png is at the midpoint of the rectangle. If we let the approximating pair be _autogen-svg2png-0087.png, we assign

    (8.29)
    _autogen-svg2png-0088.png

    As in the one-variable case, if the increments are small enough,

    (8.30)
    _autogen-svg2png-0089.png

    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 _autogen-svg2png-0090.png, 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 8.12Approximation to a joint continuous distribution
    (8.31)
    _autogen-svg2png-0091.png

    Determine _autogen-svg2png-0092.png.

    >> 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  3*(u <= t.^2)
    Use array operations on X, Y, PX, PY, t, u, and P
    >> M = (t <= 0.8)&(u > 0.1);
    >> p = total(M.*P)          % Evaluation of the integral with
    p =   0.3355                % Maple gives 0.3352455531
    

    The discrete approximation may be used to obtain approximate plots of marginal distribution and density functions.

    fig8_6_1.png
    Figure 8.10
    Marginal density and distribution function for Example 8.13.
    Example 8.13Approximate plots of marginal density and distribution functions

    _autogen-svg2png-0093.png 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]
    Enter number of X approximation points  400
    Enter number of Y approximation points  200
    Enter expression for joint density  3*u.*(u<=min(1+t,1-t))
    Use array operations on X, Y, PX, PY, t, u, and P
    >> fx = PX/dx;                % Density for X  (see Figure 8.10)
                                  % Theoretical (3/2)(1 - |t|)^2
    >> fy = PY/dy;                % Density for Y
    >> FX = cumsum(PX);           % Distribution function for X (Figure 8.10)
    >> 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.

    8.3Problems On Random Vectors and Joint Distributions*

    Two cards are selected at random, without replacement, from a standard deck. Let X be the number of aces and Y be the number of spades. Under the usual assumptions, determine the joint distribution and the marginals.

    Let X be the number of aces and Y be the number of spades. Define the events ASi, Ai, Si, and Ni, i=1,2, of drawing ace of spades, other ace, spade (other than the ace), and neither on the i selection. Let P(i,k)=P(X=i,Y=k).

    _autogen-svg2png-0004.png

    _autogen-svg2png-0005.png

    _autogen-svg2png-0006.png

    _autogen-svg2png-0007.png

    _autogen-svg2png-0008.png

    _autogen-svg2png-0009.png

    _autogen-svg2png-0010.png

    _autogen-svg2png-0011.png

    P(2,2)=P()=0

    % type npr08_01
    % file npr08_01.m
    % Solution for Exercise 1.
    X = 0:2;
    Y = 0:2;
    Pn = [132  24   0; 864 144  6; 1260 216 6];
    P = Pn/(52*51);
    disp('Data in Pn, P, X, Y')
     
    npr08_01         % Call for mfile
    Data in Pn, P, X, Y    % Result
    PX = sum(P)
    PX =  0.8507    0.1448    0.0045
    PY = fliplr(sum(P'))
    PY =  0.5588    0.3824    0.0588
    

    Two positions for campus jobs are open. Two sophomores, three juniors, and three seniors apply. It is decided to select two at random (each possible pair equally likely). Let X be the number of sophomores and Y be the number of juniors who are selected. Determine the joint distribution for the pair {X,Y} and from this determine the marginals for each.

    Let Ai,Bi,Ci be the events of selecting a sophomore, junior, or senior, respectively, on the ith trial. Let X be the number of sophomores and Y be the number of juniors selected.

    Set _autogen-svg2png-0015.png

    _autogen-svg2png-0016.png

    _autogen-svg2png-0017.png

    _autogen-svg2png-0018.png

    _autogen-svg2png-0019.png

    _autogen-svg2png-0020.png

    _autogen-svg2png-0021.png

    _autogen-svg2png-0022.png

    _autogen-svg2png-0023.png

    % file npr08_02.m
    % Solution for Exercise 2.
    X = 0:2;
    Y = 0:2;
    Pn = [6 0 0; 18 12 0; 6 12 2];
    P = Pn/56;
    disp('Data are in X, Y,Pn, P')
    npr08_02
    Data are in X, Y,Pn, P
    PX = sum(P)
    PX =  0.5357    0.4286    0.0357
    PY = fliplr(sum(P'))
    PY =  0.3571    0.5357    0.1071
    

    A die is rolled. Let X be the number that turns up. A coin is flipped X times. Let Y be the number of heads that turn up. Determine the joint distribution for the pair {X,Y}. Assume P(X=k)=1/6 for 1≤k≤6 and for each k, P(Y=j|X=k) has the binomial (k,1/2) distribution. Arrange the joint matrix as on the plane, with values of Y increasing upward. Determine the marginal distribution for Y. (For a MATLAB based way to determine the joint distribution see Example 7 from "Conditional Expectation, Regression")

    P(X=i,Y=k)=P(X=i)P(Y=k|X=i)=(1/6)P(Y=k|X=i).

    % file npr08_03.m
    % Solution for Exercise 3.
    X = 1:6;
    Y = 0:6;
    P0 = zeros(6,7);       % Initialize
    for i = 1:6            % Calculate rows of Y probabilities
        P0(i,1:i+1) = (1/6)*ibinom(i,1/2,0:i);
    end
    P = rot90(P0);         % Rotate to orient as on the plane
    PY = fliplr(sum(P'));  % Reverse to put in normal order
    disp('Answers are in X, Y, P, PY')
    npr08_03            % Call for solution m-file
    Answers are in X, Y, P, PY
    disp(P)
             0         0         0         0         0    0.0026
             0         0         0         0    0.0052    0.0156
             0         0         0    0.0104    0.0260    0.0391
             0         0    0.0208    0.0417    0.0521    0.0521
             0    0.0417    0.0625    0.0625    0.0521    0.0391
        0.0833    0.0833    0.0625    0.0417    0.0260    0.0156
        0.0833    0.0417    0.0208    0.0104    0.0052    0.0026
    disp(PY)
         0.1641  0.3125  0.2578  0.1667  0.0755  0.0208  0.0026
    

    As a variation of Exercise 3., Suppose a pair of dice is rolled instead of a single die. Determine the joint distribution for the pair {X,Y} and from this determine the marginal distribution for Y.

    % file npr08_04.m
    % Solution for Exercise 4.
    X = 2:12;
    Y = 0:12;
    PX = (1/36)*[1 2 3 4 5 6 5 4 3 2 1];
    P0 = zeros(11,13);
    for i = 1:11
        P0(i,1:i+2) = PX(i)*ibinom(i+1,1/2,0:i+1);
    end
    P = rot90(P0);
    PY = fliplr(sum(P'));
    disp('Answers are in X, Y, PY, P')
    npr08_04
    Answers are in X, Y, PY, P
    disp(P)
      Columns 1 through 7
             0         0         0         0         0         0         0
             0         0         0         0         0         0         0
             0         0         0         0         0         0         0
             0         0         0         0         0         0         0
             0         0         0         0         0         0    0.0005
             0         0         0         0         0    0.0013    0.0043
             0         0         0         0    0.0022    0.0091    0.0152
             0         0         0    0.0035    0.0130    0.0273    0.0304
             0         0    0.0052    0.0174    0.0326    0.0456    0.0380
             0    0.0069    0.0208    0.0347    0.0434    0.0456    0.0304
        0.0069    0.0208    0.0312    0.0347    0.0326    0.0273    0.0152
        0.0139    0.0208    0.0208    0.0174    0.0130    0.0091    0.0043
        0.0069    0.0069    0.0052    0.0035    0.0022    0.0013    0.0005
      Columns 8 through 11
             0         0         0    0.0000
             0         0    0.0000    0.0001
             0    0.0001    0.0003    0.0004
        0.0002    0.0008    0.0015    0.0015
        0.0020    0.0037    0.0045    0.0034
        0.0078    0.0098    0.0090    0.0054
        0.0182    0.0171    0.0125    0.0063
        0.0273    0.0205    0.0125    0.0054
        0.0273    0.0171    0.0090    0.0034
        0.0182    0.0098    0.0045    0.0015
        0.0078    0.0037    0.0015    0.0004
        0.0020    0.0008    0.0003    0.0001
        0.0002    0.0001    0.0000    0.0000
    disp(PY)
      Columns 1 through 7
        0.0269    0.1025    0.1823    0.2158    0.1954    0.1400    0.0806
      Columns 8 through 13
        0.0375    0.0140    0.0040    0.0008    0.0001    0.0000
    

    Suppose a pair of dice is rolled. Let X be the total number of spots which turn up. Roll the pair an additional X times. Let Y be the number of sevens that are thrown on the X rolls. Determine the joint distribution for the pair {X,Y} and from this determine the marginal distribution for Y. What is the probability of three or more sevens?

    % file npr08_05.m
    % Data and basic calculations for Exercise 5.
    PX = (1/36)*[1 2 3 4 5 6 5 4 3 2 1];
    X = 2:12;
    Y = 0:12;
    P0 = zeros(11,13);
    for i = 1:11
      P0(i,1:i+2) = PX(i)*ibinom(i+1,1/6,0:i+1);
    end
    P = rot90(P0);
    PY = fliplr(sum(P'));
    disp('Answers are in X, Y, P, PY')
    npr08_05
    Answers are in X, Y, P, PY
    disp(PY)
      Columns 1 through 7
        0.3072    0.3660    0.2152    0.0828    0.0230    0.0048    0.0008
      Columns 8 through 13
        0.0001    0.0000    0.0000    0.0000    0.0000    0.0000
    

    The pair _autogen-svg2png-0032.png has the joint distribution (in m-file npr08_06.m):

    (8.32)
    _autogen-svg2png-0033.png
    (8.33)
    _autogen-svg2png-0034.png

    Determine the marginal distributions and the corner values for FXY. Determine P(X+Y>2) and P(XY).

    npr08_06
    Data are in X, Y, P
    jcalc
    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
    disp([X;PX]')
       -2.3000    0.2300
       -0.7000    0.1700
        1.1000    0.2000
        3.9000    0.2020
        5.1000    0.1980
     
    disp([Y;PY]')
        1.3000    0.2980
        2.5000    0.3020
        4.1000    0.1900
        5.3000    0.2100
    jddbn
    Enter joint probability matrix (as on the plane)  P
    To view joint distribution function, call for FXY
    disp(FXY)
        0.2300    0.4000    0.6000    0.8020    1.0000
        0.1817    0.3160    0.4740    0.6361    0.7900
        0.1380    0.2400    0.3600    0.4860    0.6000
        0.0667    0.1160    0.1740    0.2391    0.2980
    P1 = total((t+u>2).*P)
    P1 =  0.7163
    P2 = total((t>=u).*P)
    P2 =  0.2799
    

    The pair _autogen-svg2png-0038.png has the joint distribution (in m-file npr08_07.m):

    (8.34)
    _autogen-svg2png-0039.png
    Table 8.1.
    t =-3.1-0.51.22.43.74.9
    u = 7.50.00900.03960.05940.02160.04400.0203
    4.10.049500.10890.05280.03630.0231
    -2.00.04050.13200.08910.03240.02970.0189
    -3.80.05100.04840.07260.013200.0077

    Determine the marginal distributions and the corner values for FXY. Determine P(1≤X≤4,Y>4) and P(|XY|≤2).

    npr08_07
    Data are in X, Y, P
    jcalc
    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
    disp([X;PX]')
       -3.1000    0.1500
       -0.5000    0.2200
        1.2000    0.3300
        2.4000    0.1200
        3.7000    0.1100
        4.9000    0.0700
    disp([Y;PY]')
       -3.8000    0.1929
       -2.0000    0.3426
        4.1000    0.2706
        7.5000    0.1939
    jddbn
    Enter joint probability matrix (as on the plane)  P
    To view joint distribution function, call for FXY
    disp(FXY)
        0.1500    0.3700    0.7000    0.8200    0.9300    1.0000
        0.1410    0.3214    0.5920    0.6904    0.7564    0.8061
        0.0915    0.2719    0.4336    0.4792    0.5089    0.5355
        0.0510    0.0994    0.1720    0.1852    0.1852    0.1929
    M = (1<=t)&(t<=4)&(u>4);
    P1 = total(M.*P)
    P1 =  0.3230
    P2 = total((abs(t-u)<=2).*P)
    P2 =  0.3357
    

    The pair _autogen-svg2png-0043.png has the joint distribution (in m-file npr08_08.m):

    (8.35)
    _autogen-svg2png-0044.png
    Table 8.2.
    t =135791113151719
    u = 120.01560.01910.00810.00350.00910.00700.00980.00560.00910.0049
    100.00640.02040.01080.00400.00540.00800.01120.00640.01040.0056
    90.01960.02560.01260.00600.01560.01200.01680.00960.00560.0084
    50.01120.01820.01080.00700.01820.01400.01960.00120.01820.0038
    30.00600.02600.01620.00500.01600.02000.02800.00600.01600.0040
    -10.00960.00560.00720.00600.02560.01200.02680.00960.02560.0084
    -30.00440.01340.01800.01400.02340.01800.02520.02440.02340.0126
    -50.00720.00170.00630.00450.01670.00900.00260.01720.02170.0223

    Determine the marginal distributions. Determine FXY(10,6) and P(X>Y).

    npr08_08
    Data are in X, Y, P
    jcalc
    - - - - - - - - -
     Use array operations on matrices X, Y, PX, PY, t, u, and P
    disp([X;PX]')
        1.0000    0.0800
        3.0000    0.1300
        5.0000    0.0900
        7.0000    0.0500
        9.0000    0.1300
       11.0000    0.1000
       13.0000    0.1400
       15.0000    0.0800
       17.0000    0.1300
       19.0000    0.0700
    disp([Y;PY]')
       -5.0000    0.1092
       -3.0000    0.1768
       -1.0000    0.1364
        3.0000    0.1432
        5.0000    0.1222
        9.0000    0.1318
       10.0000    0.0886
       12.0000    0.0918
    F = total(((t<=10)&(u<=6)).*P)
    F =   0.2982
    P = total((t>u).*P)
    P =   0.7390
    

    Data were kept on the effect of training time on the time to perform a job on a production line. X is the amount of training, in hours, and Y is the time to perform the task, in minutes. The data are as follows (in m-file npr08_09.m):

    (8.36)
    _autogen-svg2png-0047.png
    Table 8.3.
    t =11.522.53
    u = 50.0390.0110.0050.0010.001
    40.0650.0700.0500.0150.010
    30.0310.0610.1370.0510.033
    20.0120.0490.1630.0580.039
    10.0030.0090.0450.0250.017

    Determine the marginal distributions. Determine FXY(2,3) and P(Y/X≥1.25).

    npr08_09
    Data are in X, Y, P
    jcalc
    - - - - - - - - - - - -
     Use array operations on matrices X, Y, PX, PY, t, u, and P
    disp([X;PX]')
        1.0000    0.1500
        1.5000    0.2000
        2.0000    0.4000
        2.5000    0.1500
        3.0000    0.1000
    disp([Y;PY]')
        1.0000    0.0990
        2.0000    0.3210
        3.0000    0.3130
        4.0000    0.2100
        5.0000    0.0570
    F = total(((t<=2)&(u<=3)).*P)
    F =   0.5100
    P = total((u./t>=1.25).*P)
    P =   0.5570
    

    For the joint densities in Exercises 10-22 below

    1. Sketch the region of definition and determine analytically the marginal density functions fX and fY.

    2. Use a discrete approximation to plot the marginal density fX and the marginal distribution function FX.

    3. Calculate analytically the indicated probabilities.

    4. Determine by discrete approximation the indicated probabilities.

    fXY(t,u)=1 for 0≤t≤1, 0≤u≤2(1–t).

    (8.37)
    _autogen-svg2png-0053.png

    Region is triangle with vertices (0,0), (1,0), (0,2).

    (8.38)
    _autogen-svg2png-0054.png
    (8.39)
    _autogen-svg2png-0055.png
    (8.40)
    _autogen-svg2png-0056.png
    (8.41)
    _autogen-svg2png-0057.png
    (8.42)
    _autogen-svg2png-0058.png
    tuappr
    Enter matrix [a b] of X-range endpoints  [0 1]
    Enter matrix [c d] of Y-range endpoints  [0 2]
    Enter number of X approximation points  200
    Enter number of Y approximation points  400
    Enter expression for joint density  (t<=1)&(u<=2*(1-t))
    Use array operations on X, Y, PX, PY, t, u, and P
    fx = PX/dx;
    FX = cumsum(PX);
    plot(X,fx,X,FX)          % Figure not reproduced
    M1 = (t>0.5)&(u>1);
    P1 = total(M1.*P)
    P1 =  0                  % Theoretical = 0
    M2 = (t<=0.5)&(u>0.5);
    P2 = total(M2.*P)
    P2 =  0.5000             % Theoretical = 1/2
    P3 = total((u<=t).*P)
    P3 =  0.3350             % Theoretical = 1/3
    

    fXY(t,u)=1/2 on the square with vertices at _autogen-svg2png-0060.png.

    (8.43)
    _autogen-svg2png-0061.png

    The region is bounded by the lines u=1+t, u=1–t, u=3–t, and u=t–1

    (8.44)
    _autogen-svg2png-0066.png
    (8.45)
    _autogen-svg2png-0067.png
    (8.46)
    _autogen-svg2png-0068.png
    (8.47)
    _autogen-svg2png-0069.png
    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  200
    Enter number of Y approximation points  200
    Enter expression for joint density  0.5*(u<=min(1+t,3-t))& ...
      (u>=max(1-t,t-1))
    Use array operations on X, Y, PX, PY, t, u, and P
    fx = PX/dx;
    FX = cumsum(PX);
    plot(X,fx,X,FX)          % Plot not shown
    M1 = (t>1)&(u>1);
    PM1 = total(M1.*P)
    PM1 =  0.2501            % Theoretical = 1/4
    M2 = (t<=1/2)&(u>1);
    PM2 = total(M2.*P)
    PM2 =  0.0631            % Theoretical = 1/16 = 0.0625
    M3 = u<=t;
    PM3 = total(M3.*P)
    PM3 =  0.5023            % Theoretical = 1/2
    

    fXY(t,u)=4t(1–u) for 0≤t≤1, 0≤u≤1.

    (8.48)
    _autogen-svg2png-0073.png

    Region is the unit square.

    (8.49)
    _autogen-svg2png-0074.png
    (8.50)
    _autogen-svg2png-0075.png
    (8.51)
    _autogen-svg2png-0076.png
    (8.52) P 3 = ∫010t 4 t ( 1 – u ) d u d t = 5 / 6
    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  4*t.*(1 - u)
    Use array operations on X, Y, PX, PY, t, u, and P
    fx = PX/dx;
    FX = cumsum(PX);
    plot(X,fx,X,FX)           % Plot not shown
    M1 = (1/2<t)&(t<3/4)&(u>1/2);
    P1 = total(M1.*P)
    P1 =  0.0781              % Theoretical = 5/64 = 0.0781
    M2 = (t<=1/2)&(u>1/2);
    P2 = total(M2.*P)
    P2 =  0.0625              % Theoretical = 1/16 = 0.0625
    M3 = (u<=t);
    P3 = total(M3.*P)
    P3 =  0.8350              % Theoretical = 5/6 = 0.8333
    

    _autogen-svg2png-0078.png for 0≤t≤2, 0≤u≤2.

    (8.53)
    _autogen-svg2png-0081.png

    Region is the square _autogen-svg2png-0082.png.

    (8.54)
    _autogen-svg2png-0083.png
    (8.55)
    _autogen-svg2png-0084.png
    (8.56) P 3 = ∫020t ( t + u ) d u d t = 1 / 2
    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  200
    Enter number of Y approximation points  200
    Enter expression for joint density  (1/8)*(t+u)
    Use array operations on X, Y, PX, PY, t, u, and P
    fx = PX/dx;
    FX = cumsum(PX);
    plot(X,fx,X,FX)
    M1 = (t>1/2)&(u>1/2);
    P1 = total(M1.*P)
    P1 =  0.7031              % Theoretical = 45/64 = 0.7031
    M2 = (t<=1)&(u>1);
    P2 = total(M2.*P)
    P2 =  0.2500              % Theoretical = 1/4
    M3 = u<=t;
    P3 = total(M3.*P)
    P3 =  0.5025              % Theoretical = 1/2
    

    fXY(t,u)=4ue–2t for _autogen-svg2png-0087.png

    (8.57)
    _autogen-svg2png-0088.png

    Region is strip bounded by _autogen-svg2png-0089.png

    (8.58)
    _autogen-svg2png-0090.png
    (8.59)
    _autogen-svg2png-0091.png
    (8.60)
    _autogen-svg2png-0092.png
    tuappr
    Enter matrix [a b] of X-range endpoints  [0 3]
    Enter matrix [c d] of Y-range endpoints  [0 1]
    Enter number of X approximation points  400
    Enter number of Y approximation points  200
    Enter expression for joint density  4*u.*exp(-2*t)
    Use array operations on X, Y, PX, PY, t, u, and P
    M2 = (t > 0.5)&(u > 0.5)&(u<3/4);
    p2 = total(M2.*P)
    p2 =  0.1139            % Theoretical = (5/16)exp(-1) = 0.1150
    p3 = total((t<u).*P)
    p3 =  0.7047            % Theoretical = 0.7030
    

    _autogen-svg2png-0093.png for 0≤t≤2, 0≤u≤1+t.

    (8.61)
    _autogen-svg2png-0096.png

    Region bounded by _autogen-svg2png-0097.png

    (8.62)
    _autogen-svg2png-0098.png
    (8.63)
    _autogen-svg2png-0099.png
    (8.64)
    _autogen-svg2png-0100.png
    (8.65) FXY ( 1 , 1 ) = ∫0101 fXY ( t , u ) d u d t = 3 / 44
    (8.66)
    _autogen-svg2png-0102.png
    tuappr
    Enter matrix [a b] of X-range endpoints  [0 2]
    Enter matrix [c d] of Y-range endpoints  [0 3]
    Enter number of X approximation points  200
    Enter number of Y approximation points  300
    Enter expression for joint density  (3/88)*(2*t+3*u.^2).*(u<=1+t)
    Use array operations on X, Y, PX, PY, t, u, and P
    fx = PX/dx;
    FX = cumsum(PX);
    plot(X,fx,X,FX)
    MF = (t<=1)&(u<=1);
    F = total(MF.*P)
    F =   0.0681            % Theoretical = 3/44 = 0.0682
    M1 = (t<=1)&(u>1);
    P1 = total(M1.*P)
    P1 =  0.1172            % Theoretical = 41/352 = 0.1165
    M2 = abs(t-u)<1;
    P2 = total(M2.*P)
    P2 =  0.9297           % Theoretical = 329/352 = 0.9347
    

    fXY(t,u)=12t2u on the parallelogram with vertices _autogen-svg2png-0104.png

    (8.67)
    _autogen-svg2png-0105.png

    Region bounded by _autogen-svg2png-0106.png

    (8.68)
    _autogen-svg2png-0107.png
    (8.69)
    _autogen-svg2png-0108.png
    (8.70)
    _autogen-svg2png-0109.png
    (8.71) P 3 = 1 – P 2 = 13 / 16
    tuappr
    Enter matrix [a b] of X-range endpoints  [-1 1]
    Enter matrix [c d] of Y-range endpoints  [0 1]
    Enter number of X approximation points  400
    Enter number of Y approximation points  200
    Enter expression for joint density  12*u.*t.^2.*((u<=t+1)&(u>=t))
    Use array operations on X, Y, PX, PY, t, u, and P
    p1 = total((t<=1/2).*P)
    p1 =  0.4098                % Theoretical = 33/80 = 0.4125
    M2 = (t<1/2)&(u<=1/2);
    p2 = total(M2.*P)
    p2 =  0.1856                % Theoretical = 3/16  = 0.1875
    P3 = total((u>=1/2).*P)
    P3 =  0.8144                % Theoretical = 13/16 = 0.8125
    

    _autogen-svg2png-0111.png for 0≤t≤2, 0≤u≤min{1,2–t}

    (8.72)
    _autogen-svg2png-0114.png

    Region is bounded by _autogen-svg2png-0115.png

    (8.73)
    _autogen-svg2png-0116.png
    (8.74)
    _autogen-svg2png-0117.png
    (8.75)
    _autogen-svg2png-0118.png
    (8.76)
    _autogen-svg2png-0119.png
    (8.77)
    _autogen-svg2png-0120.png
    tuappr
    Enter matrix [a b] of X-range endpoints  [0 2]
    Enter matrix [c d] of Y-range endpoints  [0 1]
    Enter number of X approximation points  400
    Enter number of Y approximation points  200
    Enter expression for joint density  (24/11)*t.*u.*(u<=2-t)
    Use array operations on X, Y, PX, PY, t, u, and P
    M1 = (t<=1)&(u<=1);
    P1 = total(M1.*P)
    P1 = 0.5447             % Theoretical = 6/11 = 0.5455
    P2 = total((t>1).*P)
    P2 =  0.4553            % Theoretical = 5/11 = 0.4545
    P3 = total((t<u).*P)
    P3 =  0.2705            % Theoretical = 3/11 = 0.2727
    

    _autogen-svg2png-0121.png for 0≤t≤2, 0≤u≤max{2–t,t}

    (8.78)
    _autogen-svg2png-0124.png

    Region is bounded by _autogen-svg2png-0125.png

    (8.79)
    _autogen-svg2png-0126.png
    (8.80)
    _autogen-svg2png-0127.png
    (8.81)
    _autogen-svg2png-0128.png
    (8.82)
    _autogen-svg2png-0129.png
    (8.83)
    _autogen-svg2png-0130.png
    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  200
    Enter number of Y approximation points  200
    Enter expression for joint density  (3/23)*(t+2*u).*(u<=max(2-t,t))
    Use array operations on X, Y, PX, PY, t, u, and P
    M1 = (t>=1)&(u>=1);
    P1 = total(M1.*P)
    P1 =  0.2841
    13/46                 % Theoretical = 13/46 = 0.2826
    P2 = total((u<=1).*P)
    P2 =  0.5190             % Theoretical = 12/23 = 0.5217
    P3 = total((u<=t).*P)
    P3 =  0.6959             % Theoretical = 16/23 = 0.6957
    

    _autogen-svg2png-0131.png, for 0≤t≤2, 0≤u≤min{2,3–t}

    (8.84) P ( X ≥ 1 , Y ≥ 1 ) , P ( X ≤ 1 , Y ≤ 1 ) , P ( Y < X )

    Region has two parts: (1) 0≤t≤1,0≤u≤2 (2) 1<t≤2,0≤u≤3–t

    (8.85)
    _autogen-svg2png-0137.png
    (8.86)
    _autogen-svg2png-0138.png
    (8.87)
    _autogen-svg2png-0139.png
    (8.88)
    _autogen-svg2png-0140.png
    (8.89)
    _autogen-svg2png-0141.png
    (8.90)
    _autogen-svg2png-0142.png
    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  200
    Enter number of Y approximation points  200
    Enter expression for joint density  (12/179)*(3*t.^2+u).* ...
         (u<=min(2,3-t))
    Use array operations on X, Y, PX, PY, t, u, and P
    fx = PX/dx;
    FX = cumsum(PX);
    plot(X,fx,X,FX)
    M1 = (t>=1)&(u>=1);
    P1 = total(M1.*P)
    P1 =  2312            % Theoretical = 41/179 = 0.2291
    M2 = (t<=1)&(u<=1);
    P2 = total(M2.*P)
    P2 =  0.1003           % Theoretical = 18/179 = 0.1006
    M3 = u<=min(t,3-t);
    P3 = total(M3.*P)
    P3 =  0.7003            % Theoretical = 1001/1432 = 0.6990
    

    _autogen-svg2png-0143.png for 0≤t≤2, 0≤u≤min{1+t,2}

    (8.91)
    _autogen-svg2png-0146.png

    Region is in two parts:

    1. _autogen-svg2png-0147.png

    2. (2) _autogen-svg2png-0148.png

    (8.92) fX ( t ) = I [ 0 , 1 ] ( t ) ∫0 1 + t fXY ( t , u ) d u + I ( 1 , 2 ] ( t ) ∫02 fXY ( t , u ) d u =
    (8.93)
    _autogen-svg2png-0150.png
    (8.94) fY ( u ) = I [ 0 , 1 ] ( u ) ∫02 fXY ( t , u ) d t + I ( 1 , 2 ] ( u ) ∫2 u – 1 fXY ( t , u ) d t =
    (8.95)
    _autogen-svg2png-0152.png
    (8.96)
    _autogen-svg2png-0153.png
    (8.97)
    _autogen-svg2png-0154.png
    (8.98)
    _autogen-svg2png-0155.png
    (8.99)
    _autogen-svg2png-0156.png
    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  200
    Enter number of Y approximation points  200
    Enter expression for joint density  (12/227)*(3*t+2*t.*u).* ...
    (u<=min(1+t,2))
    Use array operations on X, Y, PX, PY, t, u, and P
    M1 = (t<=1/2)&(u<=3/2);
    P1 = total(M1.*P)
    P1 =  0.0384             % Theoretical = 139/3632 = 0.0383
    M2 = (t<=3/2)&(u>1);
    P2 = total(M2.*P)
    P2 =  0.3001             % Theoretical = 68/227 = 0.2996
    M3 = u<t;
    P3 = total(M3.*P)
    P3 =  0.6308             % Theoretical = 144/227 = 0.6344
    

    _autogen-svg2png-0157.png for 0≤t≤2, 0≤u≤min{2t,3–t}

    (8.100)
    _autogen-svg2png-0160.png

    Region bounded by _autogen-svg2png-0161.png

    (8.101)
    _autogen-svg2png-0162.png
    (8.102)
    _autogen-svg2png-0163.png
    (8.103)
    _autogen-svg2png-0164.png
    (8.104)
    _autogen-svg2png-0165.png
    (8.105) P 3 = ∫020 t / 2 ( t + 2 u ) d u d t = 4 / 13
    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  400
    Enter number of Y approximation points  400
    Enter expression for joint density  (2/13)*(t+2*u).*(u<=min(2*t,3-t))
    Use array operations on X, Y, PX, PY, t, u, and P
    P1 = total((t<1).*P)
    P1 = 0.3076             % Theoretical = 4/13 = 0.3077
    M2 = (t>=1)&(u<=1);
    P2 = total(M2.*P)
    P2 =  0.3844            % Theoretical = 5/13 = 0.3846
    P3 = total((u<=t/2).*P)
    P3 =  0.3076             % Theoretical = 4/13 = 0.3077
    

    _autogen-svg2png-0167.png for 0≤u≤1.

    (8.106) P ( 1 / 2 ≤ X ≤ 3 / 2 , Y ≤ 1 / 2 )

    Region is rectangle bounded by _autogen-svg2png-0170.png

    (8.107)
    _autogen-svg2png-0171.png
    (8.108)
    _autogen-svg2png-0172.png
    (8.109)
    _autogen-svg2png-0173.png
    (8.110)
    _autogen-svg2png-0174.png
    tuappr
    Enter matrix [a b] of X-range endpoints  [0 2]
    Enter matrix [c d] of Y-range endpoints  [0 1]
    Enter number of X approximation points  400
    Enter number of Y approximation points  200
    Enter expression for joint density  (3/8)*(t.^2+2*u).*(t<=1) ...
           + (9/14)*(t.^2.*u.^2).*(t > 1)
    Use array operations on X, Y, PX, PY, t, u, and P
    M = (1/2<=t)&(t<=3/2)&(u<=1/2);
    P = total(M.*P)
    P =  0.1228          % Theoretical = 55/448 = 0.1228
    
    Solutions