Random Signals for Engineers using MATLAB and Mathcad Copyright 1999 Springer Verlag NY Example 4.2 Continuous Density Functions In this example we will compute the cumulative distribution function. Let us begin with the density function over a range 0 <x < b and 0 < y < syms u v b C pretty (C*exp(-u-v)) C exp(-u - v) The normalization constant is obtained by integrating over the range and setting it equal to 1 or FI=int(int(C*exp(-u-v),u,0,b),v,0,inf); Performing the integrations using Matlab and solving for C we have C=solve(FI-1,C) C = -1/(exp(-b)-1) The cumulative distribution function can be found by evaluating the expression syms x y CT F=int(int(CT*exp(-u-v),u,0,x),v,0,y); F=simplify(F); F=expand(F); prettY(F) CT CT CT ------------- - ------ - ------ + CT exp(y) exp(x) exp(x) exp(y) We may indeed verify that the density function results by differentiating F(x,y) with respect to x and y as f=diff(diff(F,x),y) f = CT/exp(y)/exp(x) The marginal distributions can be found by integrating over the x range for f(y) and the y range for f(x) f=subs(f,x,u); fy=int(f,u,0,b) fy = -CT*exp(-y-b)+CT*exp(-y) It is possible to reduce the expression by substitution for C and simplifying. Some rearranging and factoring is needed to help Matlab recognize the simplifications fy=subs(fy,CT,C); pretty(fy) exp(-y - b) exp(-y) ----------- - ----------exp(-b) - 1 exp(-b) - 1 fy=expand(fy); fy=factor(fy); pretty(fy) 1 -----exp(y) The range of y is 0 < y < Similarly we may find the marginal f(x). We must restore the original function f(x,y) f=subs(f,y,v); f=subs(f,u,x); fx=int(f,v,0,inf) fx=subs(fx,CT,C); pretty(fx) fx = CT*exp(-x) exp(-x) - ----------exp(-b) - 1 For values of 0< x < b. The marginal density functions can be plotted over 0 < x < 1 and 0 < y <10. We assume that y= 10 is equivalent to y = We use the step function (In Maple the Heaviside function) to limit the range of x in the plot C0=double(subs(C,b,1)) C0 = 1.5820 xp=-.1:0.051:5; fx=C0*exp(-x); fxp=subs(fx,x,xp).*( mfun('Heaviside',xp) 1)); fx=C0*exp(-x); fy=exp(-y) mfun('Heaviside',xp- fyp=subs(fy,y,xp).*mfun('Heaviside',xp); plot(xp,fxp,xp,fyp) fy = exp(-y) 1.6 1.4 1.2 1 0.8 0.6 0.4 0.2 0 -1 0 1 2 3 4 5 The cumulative distribution function associated with the marginal function can be computed FX=int(CT*exp(-u),u,0,x) FX = -CT*exp(-x)+CT and similarly for y FY=int(exp(-v),v,0,y) FY = -exp(-y)+1 The distribution can be plotted over their ranges respectively C0=double(subs(C,b,1)); FX=subs(FX,CT,C0); FXP=subs(FX,x,xp).*( mfun('Heaviside',xp) 1)); FY=1-exp(-y) FYP=subs(FY,y,xp).*mfun('Heaviside',xp); plot(xp,FXP,xp,FYP) FY = 1-exp(-y) mfun('Heaviside',xp- 1 0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0 -1 0 1 2 3 4 5