Home > sp > remaining.m

remaining

PURPOSE ^

remaining.m computes and graphs the remaining lifetime distribution

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

 remaining.m computes and graphs the remaining lifetime distribution
 for continuous interrenewal distributions

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % remaining.m computes and graphs the remaining lifetime distribution
0002 % for continuous interrenewal distributions
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 %---------------------------------------------------------------------------
0009 
0010 f = unifpdf(t,0,6);
0011 F = cumsum(f)/n;    % the cdf for interrenewal times
0012                     % 1/n is like delta x in the integral
0013 g = (1-F)/(sum(1-F)/n);
0014 
0015 subplot(2,4,1)
0016 plot(t,f);
0017 axis([0 10 0 0.2]);
0018 title('Uniform(0,6) interarrival time');
0019 
0020 subplot(2,4,5)
0021 plot(t,g);
0022 title('Remaining lifetime density');
0023 
0024 %---------------------------------------------------------------------------
0025 
0026 f=zeros(1,N);
0027 f(1:n) = 1:n;       % f is defined for times 1/n, 2/n, ...
0028 f(3*n+1:4*n) = n:(-1):1;
0029 
0030 f = exppdf(t,1);    % exponential case
0031 F = cumsum(f)/n;    % the cdf for interrenewal times
0032                     % divide by n to make F approach 1
0033 g = (1-F)/(sum(1-F)/n);
0034 
0035 subplot(2,4,2)
0036 plot(t,f);
0037 title('Exponential(1) interarrival time');
0038 
0039 subplot(2,4,6)
0040 plot(t,g);
0041 title('Remaining lifetime density');
0042 
0043 %---------------------------------------------------------------------------
0044 
0045 f = gampdf(t,4,1);  % generic gamma case
0046 F = cumsum(f)/n;    % the cdf for interrenewal times
0047                     % 1/n is like delta x in the integral
0048 g = (1-F)/(sum(1-F)/n);
0049 
0050 subplot(2,4,3)
0051 plot(t,f);
0052 title('Gamma(4,1) interarrival time');
0053 
0054 subplot(2,4,7)
0055 plot(t,g);
0056 title('Remaining lifetime density');
0057 
0058 %---------------------------------------------------------------------------
0059 
0060 f = unifpdf(t,8,9);
0061 f(9*n) = 0;         % small fix
0062 F = cumsum(f)/n;    % the cdf for interrenewal times
0063                     % 1/n is like delta x in the integral
0064 g = (1-F)/(sum(1-F)/n);
0065 
0066 subplot(2,4,4)
0067 plot(t,f);
0068 axis([0 10 0 1.1]);
0069 title('Uniform(8,9) interarrival time');
0070 
0071 subplot(2,4,8)
0072 plot(t,g);
0073 title('Remaining lifetime density');
0074

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