plot cdf and calculate 90th percentile value
23 views (last 30 days)
Show older comments
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.
0 Comments
Answers (1)
Star Strider
on 23 Oct 2020
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:
.
0 Comments
See Also
Categories
Find more on Geographic Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!