www.gusucode.com > stats 源码程序 matlab案例代码 > stats/ReturnHistogramBarHeightsandBinCentersExample.m
%% Return Histogram Bar Heights and Bin Centers % Compute the histogram bar heights based on the empirical cumulative distribution % function. % Copyright 2015 The MathWorks, Inc. %% % Generate failure times from a Birnbaum-Saunders distribution. rng('default') % for reproducibility failuretime = random('birnbaumsaunders',0.3,1,100,1); %% % Assuming that the end of the study is at time 0.9, mark the generated % failure times that are larger than 0.9 as censored data and store that % information in a vector. T = 0.9; cens = (failuretime>T); %% % Compute the empirical cumulative distribution function for the data. [f,x] = ecdf(failuretime,'censoring',cens); %% % Now, find the bar heights of the histogram using the cumulative distribution % function estimate. [n,c] = ecdfhist(f,x); [n' c']