www.gusucode.com > stats 源码程序 matlab案例代码 > stats/EmpiricalSurvivorFunctionwith99ConfidenceBoundsExample.m

    %% Empirical Survivor Function with 99% Confidence Bounds  
% Generate survival data and plot the empirical survivor function with 99%
% confidence bounds.   

% Copyright 2015 The MathWorks, Inc.


%% 
% Generate lifetime data from a Weibull distribution with parameters 100 and 2. 
rng default  % for reproducibility 
R = wblrnd(100,2,100,1);  

%% 
% Plot the survivor function for the data with 99% confidence bounds. 
ecdf(R,'function','survivor','alpha',0.01,'bounds','on')
hold on  

%% 
% Fit the Weibull survivor function. 
x = 1:1:250;
wblsurv = 1-cdf('weibull',x,100,2);
plot(x,wblsurv,'g-','LineWidth',2)
legend('Empirical','LCB','UCB','Population',...
'Location','NE')    

%%
% The survivor function based on the actual distribution is within the confidence
% bounds.