How to plot empirical cdf and fitted distributions cdfs?
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi, want to make one plot with the empirical CDF and three additional distributions CDFs (normal, lognormal, and weibull) to visually compare goodness of fit. (This is a smaller subset of data).
But, the x-axis of the fitted distributions goes to 1, whereas the empirical CDF goes to 2310. How can I make the x-axis to represent the table values, and the how do I overlay the plots so they are all in one plot?
Table = readtable("practice3.xlsx");
a = Table.values;
cdfplot(a); % Make a plot of the empirical CDF
% fit the normal, lognormal, and weibull distributions to the data
pd_normal = fitdist(a,'Normal');
pd_lognormal = fitdist (a, 'Lognormal');
pd_weibull = fitdist(a,"Weibull");
% generate CDF values for each of the fitted distributions
cdf_n = cdf(pd_normal,a);
cdf_l = cdf(pd_lognormal,a);
cdf_w = cdf(pd_weibull,a);
% plot the three distributions cdfs
figure;
hold on;
cdfplot(cdf_n)
cdfplot(cdf_l)
cdfplot(cdf_w)
grid on;
hold off;
%The x-axis of the fitted distributions goes to 1. How do I overlay the
%fitted distributions over the empirical distribution? The x-axis should go
%to 2500.
0 commentaires
Réponse acceptée
Torsten
le 13 Fév 2023
Table = readtable("practice3.xlsx");
a = Table.values;
a = sort(a);
hold on
cdfplot(a); % Make a plot of the empirical CDF
% fit the normal, lognormal, and weibull distributions to the data
pd_normal = fitdist(a,'Normal');
pd_lognormal = fitdist (a, 'Lognormal');
pd_weibull = fitdist(a,'Weibull');
% generate CDF values for each of the fitted distributions
cdf_n = cdf('Normal',a,pd_normal.mu,pd_normal.sigma);
cdf_l = cdf('LogNormal',a,pd_lognormal.mu,pd_lognormal.sigma);
cdf_w = cdf('Weibull',a,pd_weibull.A,pd_weibull.B);
% plot the three distributions cdfs
plot(a,cdf_n)
plot(a,cdf_l)
plot(a,cdf_w)
hold off
grid on
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!