plot cdf and calculate 90th percentile value

63 ビュー (過去 30 日間)
Sajid Afaque
Sajid Afaque 2020 年 10 月 23 日
回答済み: Star Strider 2020 年 10 月 23 日
hello all ,
i have a variable z_cdf attached;
prctile(z_cdf,90) % answer is 30.9361
now using z_cdf i am trying to plot cdf.
[f,x] = ecdf(z_cdf);
plot(x,f,'HandleVisibility','off','color',[1 0 0],'LineWidth',2);
now in the plot i need to show the line representing the 90th percentile value as shown in the below figure. i.e. the line corresponding to cdf / y-axis= 0.9;
please help me with the line plotting option and also
according to plot x-axis value corresponding to y-axis value 0.9 is 30.7553. why is this x value not equal to prctile(z_cdf,90).
help me with similar cdf plot options where prctile(z_cdf,90) matches (prctile(z_cdf,90),0.9) in plot.

回答 (1 件)

Star Strider
Star Strider 2020 年 10 月 23 日
To plot the dashed lines at the appropriate percentiles:
pctl = [50 90];
pctlv = prctile(z_cdf,[50 90]); % answer is 30.9361
[f,x] = ecdf(z_cdf);
figure
plot(x,f,'color',[1 0 0],'LineWidth',2)
hold on
for k = 1:numel(pctl)
plot([1;1]*pctlv(k), [0;1]*pctl(k)/100, '--k')
plot([0;1]*pctlv(k), [1;1]*pctl(k)/100, '--k')
end
hold off
producing:
.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by