<< Chapter < Page Chapter >> Page >
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 vector W = ( 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 t i and corresponding probabilities P ( X = t i ) arranged in matrices

X = [ t 1 , t 2 , , t n ] and P X = [ P ( X = t 1 ) , P ( X = t 2 ) , , P ( X = t n ) ]

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

G = [ g ( t 1 ) g ( t 2 ) g ( t n ) ]

which has g ( t i ) in a position corresponding to P ( X = t i ) in matrix P X .

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 ( t i ) M . These will be in a zero-one matrix N , with ones in the desired positions.
  • Select the P ( X = t i ) in the corresponding positions and sum. This is accomplished by one of the MATLAB operations to determine the inner product of N and P X

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
    X = [ t 1 t 2 t n ] and Y = [ u 1 u 2 u m ]
    and the joint probabilities P ( X = t i , Y = u j ) in a matrix P . We usually represent the distribution graphically by putting probability mass P ( X = t i , Y = u j ) at the point ( t i , u j ) 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
    P has element P ( X = t i , Y = u j ) at the ( t i , u j ) position
  2. To perform calculations, we form computational matrices t and u such that — t has element t i at each ( t i , u j ) position (i.e., at each point on the i th column from the left) — u has element u j at each ( t i , u j ) position (i.e., at each point on the j th row from the bottom) MATLAB array and logical operations on t , u , P perform the specified operations on t i , u j , and P ( X = t i , Y = u j ) at each ( t i , u j ) 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: X = [ t 1 , t 2 , , t n ] is the set of values for random variable X Y = [ u 1 , u 2 , , u m ] is the set of values for random variable Y , and P = [ p i j ] , where p i j = P ( X = t i , Y = u j ) . 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 thisinversion. 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.

    Setup and basic calculations

    >>jdemo4 % Call for data in file jdemo4.m>>jcalc % Call for setup procedure Enter JOINT PROBABILITIES (as on the plane) PEnter row matrix of VALUES of X X Enter row matrix of VALUES of Y YUse 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.01800.0372 0.0558 0.0837 0.0589 0.0744 0.0516 0.0774 0.1161 0.0817 0.10320.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 (increasing1 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 P ( X 2 - 3 Y 1 ) . Using array operations on t and u , we obtain the matrix G = [ g ( t i , u j ) ] . >>G = t.^2 - 3*u % Formation of G = [g(t_i,u_j)] matrixG = 3 -6 -5 3 19 6 -3 -2 6 229 0 1 9 25 15 6 7 15 31>>M = G>= 1 % Positions where G>= 1 M = 1 0 0 1 11 0 0 1 1 1 0 1 1 11 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.07440.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)

    Got questions? Get instant answers now!
  4. In Example 3 from "Random Vectors and Joint Distributions" we note that the joint distribution function F X Y 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-handcorner 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 desiredresults.

    Calculation of F X Y 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.10000 0 0.1000>>FXY = cumsum(FXY')' % Cumulative row sums FXY =0.3000 0.9000 1.0000 0 0.6000 0.70000 0 0.1000
    Got questions? Get instant answers now!
    A graph creating a 2x2 grid with three points indicated by black dots. the upper most of these dots is present on the y axis and is labeled 3/10 the next highest point is in the center of the grid and is labeled 6/10 and finally the lowest point is on the far bottom right of the grid on the x-axis and is labeled 1/10. A graph creating a 2x2 grid with three points indicated by black dots. the upper most of these dots is present on the y axis and is labeled 3/10 the next highest point is in the center of the grid and is labeled 6/10 and finally the lowest point is on the far bottom right of the grid on the x-axis and is labeled 1/10.
    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 [link]

    Joint distribution function for [link]

    >>jddbn Enter joint probability matrix (as on the plane) PTo view joint distribution function, call for FXY>>disp(FXY) 0.1512 0.3312 0.6012 0.7912 1.00000.1152 0.2754 0.5157 0.6848 0.8756 0.0780 0.1824 0.3390 0.4492 0.56560.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".

    Got questions? Get instant answers now!
  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 theoutputs conveniently. function [x,y,t,u,px,py,p] = jcalcf(X,Y,P) The quantities x , y , t , u , p x , p y , and p may be given any desired names.

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Applied probability. OpenStax CNX. Aug 31, 2009 Download for free at http://cnx.org/content/col10708/1.6
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Applied probability' conversation and receive update notifications?

Ask