ex5m2_4.doc

advertisement
Random Signals for Engineers using MATLAB and Mathcad
Copyright  1999 Springer Verlag NY
Example 2.4 Uniform Probability Functions
In this example we will derive the probability distribution function for the uniform density
function and illustrate how this probability function is applied to problem analysis. The uniform
density function can be defined using the unit step function as
f x  
1
 u  x  a   u  x  b 
ba
The distribution function can be found by symbolically integrating the constant over the non-zero
interval of the function as
syms x t a b
F=1/(b-a)*int(1,x,a,t);
pretty(F)
t - a
----b - a
The distribution function must be rewritten with step functions to be able to obtain an expression
that is valid over the entire x domain.
F x  
xa
 u  x  a   u  x  b   u  x  b 
ba
The uniform density and distribution function can be plotted over the nonzero domain of x
a=0;
b=2;
ti=0:0.05:3.0;
t=ti-.5;
plot(t,f2_4_1(a,b,t),t,f2_4_2(a,b,t))
1
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
-0.5
0
0.5
1
1.5
2
2.5
The following example illustrates the use of the uniform distribution functions.
PROBLEM: A railroad notifies the passengers of a train that they will arrive at their destination
in a city between 2 and 5 PM. It is assumed that the arrival time is uniformly distributed in this
interval of time. If we want to meet a passenger that is on this train what is the probability that he
will arrive before 3 PM? After 3 PM and between 4 and 5 PM?
SOLUTION: The following probability statement can be set up corresponding to the three
questions and evaluated using the distribution function derived above. We must first change a = 2
and b = 5 and redefine the distribution function
Before 3 PM ?
P[t < 3] = FD(3)
FD=f2_4_2(2,5,3)
FD =
0.3333
After 3 PM ?
P[t > 3] = 1 - P[t < 3] = 1- FD(3)
1-FD
ans =
0.6667
Between 4 and 5 PM P[ 4< t < 5] =
f2_4_2(2,5,5)-f2_4_2(2,5,4)
ans =
0.3333
The step functions are used to limit the range of the function.
function y=f2_4_1(a,b,t)
% f2_4_1 is the uniform density function
% where a,b = start and stop values
% t = time vector
y=zeros(1,length(t));
y = 1/(b-a)*(stepfun(t,a)-stepfun(t,b));
function y=f2_4_2(a,b,t)
% f2_4_1 is the uniform cumulative distribution function
% where a,b = start and stop values
% t = time vector
y=zeros(1,length(t));
t1=ones(1,length(t));
y = 1/(b-a)*(t-a*t1).*(stepfun(t,a)-stepfun(t,b))+stepfun(t,b);

Download