Histogram based on empirical cumulative distribution function

您所在的位置:网站首页 ecdfhist函数 Histogram based on empirical cumulative distribution function

Histogram based on empirical cumulative distribution function

2023-08-31 12:41| 来源: 网络整理| 查看: 265

Open Live Script

Generate right-censored survival data and compare the histogram from cumulative distribution function with the known probability distribution function.

Generate failure times from an exponential distribution with mean failure time of 15.

rng default; % For reproducibility y = exprnd(15,75,1);

Generate drop-out times from an exponential distribution with mean failure time of 30.

d = exprnd(30,75,1);

Record the minimum of these times as the observed failure times.

t = min(y,d);

Generate censoring by finding the generated failure times that are greater than the drop-out times.

censored = (y>d);

Calculate the empirical cdf and plot a histogram using the empirical cumulative distribution function.

[f,x] = ecdf(t,'censoring',censored); ecdfhist(f,x) h = findobj(gca,'Type','patch'); h.FaceColor = [.8 .8 1]; hold on

Superimpose a plot of the known population pdf.

xx = 0:.1:max(t); yy = exp(-xx/15)/15; plot(xx,yy,'r-','LineWidth',2) hold off



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3