<< Chapter < Page Chapter >> Page >

We first examine the basic calculations, which are then implemented in the m-procedure jointzw .

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 94 4 4 4 4 1 1 1 1 10 0 0 0 0 1 1 1 1 14 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 22 1 0 1 2 2 1 0 1 22 1 0 1 2 2 1 0 1 2[W,PW] = csort(H,P) % Determination of marginal for WW = 0 1 4 9 PW = 0.1490 0.3530 0.3110 0.1870[Z,PZ] = csort(G,P) % Determination of marginal for ZZ = 0 1 2 PZ = 0.2670 0.3720 0.3610r = W(3) % Third value for W r = 4s = 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 jointprobability matrix P Z W 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 26 2 2 46 4 a = find((H==W(3))&(G==Z(2))); % Location in more convenient form P0 = zeros(size(P)); % Setup of zero matrixP0(a) = P(a) % Display of designated probabilities in P P0 =0 0 0 0 0 0 0.0010 0 0.0580 00 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0.0520 0 0.0010 0PZW = zeros(length(W),length(Z)) % Initialization of PZW matrix PZW(3,2) = total(P(a)) % Assignment to PZW matrix withPZW = 0 0 0 % W increasing downward 0 0 00 0.1120 0 0 0 0 PZW = flipud(PZW) % Assignment with W increasing upward PZW =0 0 0 0 0.1120 00 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).

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