www.gusucode.com > stats 源码程序 matlab案例代码 > stats/EstimateSurvivorandCumHazardforCensoredFailureDataExample.m
%% Estimate Survivor and Cumulative Hazard for Censored Failure Data % Copyright 2015 The MathWorks, Inc. %% % Generate sample data from an exponential distribution with mean 3. rng default % for reproducibility x = random('exp',3,100,1); %% % Create a logical vector that indicates censoring. Here, observations with % lifetimes longer than 10 are censored. T = 10; cens = (x>10); %% % Compute and plot the estimated density function. figure ksdensity(x,'support','positive','censoring',cens); %% % Compute and plot the survivor function. figure ksdensity(x,'support','positive','censoring',cens,... 'function','survivor'); %% % Compute and plot the cumulative hazard function. figure ksdensity(x,'support','positive','censoring',cens,... 'function','cumhazard');