Home > sp > renewal.m

renewal

PURPOSE ^

renewal.m computes and graphs the renewal function for Uniform(0,1)

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

 renewal.m computes and graphs the renewal function for Uniform(0,1)
 interrenewal times

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % renewal.m computes and graphs the renewal function for Uniform(0,1)
0002 % interrenewal times
0003 
0004 N = 2000; 
0005 n = 200;        % number of points in the interval [0,1]
0006 t = (1:N)/n;    % vector of times
0007 
0008 f=zeros(1,N);
0009 f(n+1:2*n) = 1;     % f is defined for times 1/n, 2/n, ...
0010 
0011 G = cumsum(f)/n;    % the cdf for interrenewal times
0012                     % divide by n to make G approach 1
0013 R = ones(1,N) + G;  % begin adding terms in the renewal function
0014 
0015 for i=1:15,
0016   h = conv(f,G)/n;  % think of 1/n as delta x in the integral
0017   G = h(1:N);
0018   R = R + G;  
0019 end
0020 
0021 subplot(2,2,1)
0022 
0023 plot(t,f);
0024 axis([0 10 0 1.5]);
0025 title('Density of interarrival time #1');
0026 
0027 subplot(2,2,3)
0028 
0029 plot(t,R);
0030 title('Renewal function #1');
0031 axis([0 10 0 8]);
0032 
0033 %---------------------------------------------------------------------------
0034 
0035 f=zeros(1,N);
0036 f(1:n) = 1:n;     % f is defined for times 1/n, 2/n, ...
0037 f(3*n+1:4*n) = n:(-1):1;
0038 
0039 f=n*f/sum(f);
0040 
0041 G = cumsum(f)/n;
0042 R = ones(1,N) + G;  % begin adding terms in the renewal function
0043 
0044 for i=1:15,
0045   h = conv(f,G)/n;
0046   G = h(1:N);
0047   R = R + G;  
0048 end
0049 
0050 subplot(2,2,2)
0051 
0052 plot(t,f);
0053 axis([0 10 0 1.5]);
0054 title('Density of interarrival time #2');
0055 
0056 subplot(2,2,4)
0057 
0058 plot(t,R);
0059 title('Renewal function #2');
0060 axis([0 10 0 6]);
0061

Generated on Mon 17-Mar-2008 10:33:42 by m2html © 2003