% TUAPPR file tuappr.m Discrete approximation to joint ac pair % Version of 2/20/96 % Joint density entered as a function of t, u % Sets up discrete approximations to X, Y, t, u, and density rx = input('Enter matrix [a b] of X-range endpoints '); ry = input('Enter matrix [c d] of Y-range endpoints '); nx = input('Enter number of X approximation points '); ny = input('Enter number of Y approximation points '); dx = (rx(2) - rx(1))/nx; dy = (ry(2) - ry(1))/ny; X = (rx(1):dx:rx(2)-dx) + dx/2; Y = (ry(1):dy:ry(2)-dy) + dy/2; [t,u] = meshgrid(X,fliplr(Y)); P = input('Enter expression for joint density '); P = dx*dy*P; P = P/sum(sum(P)); PX = sum(P); PY = fliplr(sum(P')); disp('Use array operations on X, Y, PX, PY, t, u, and P')