# How to plot probability density curve?

10 views (last 30 days)
Andi on 8 Dec 2021
Commented: Andi on 30 Mar 2022
I have modify the strip as per my data but its the resulst are not expected. Why the movemedian=25 is fixed here.
r_a=[X(1,:)];
r_b=[X(2,:)];
r_c=[X(3,:)];
r_d=[X(4:8,:)];
r_e=[X(9:12,:)];
r_f=[X(13:16,:)];
r_g=[X(17:26,:)];
r_h=[X(27:48,:)];
r_i=[X(49:120,:)];
r_j=[X(121:186,:)];
r_aam = (r_a(~isnan(r_a)));
r_abm = r_b(~isnan(r_b));
r_acm = r_c(~isnan(r_c));
r_aem = r_e(~isnan(r_e));
r_afm = r_f(~isnan(r_f));
r_agm = r_g(~isnan(r_g));
r_ahm = r_h(~isnan(r_h));
r_aim = r_i(~isnan(r_i));
r_ajm= r_j(~isnan(r_j));
pd = makedist('Normal')
[f1,x1,flo1,fup1] = ecdf(r_aam);
[f2,x2,flo2,fup2] = ecdf(r_abm);
[f3,x3,flo3,fup3] = ecdf(r_acm);
[f5,x5,flo5,fup5] = ecdf(r_aem);
[f6,x6,flo6,fup6] = ecdf(r_afm);
[f7,x7,flo7,fup7] = ecdf(r_agm);
[f8,x8,flo8,fup8] = ecdf(r_ahm);
[f9,x9,flo9,fup9] = ecdf(r_aim);
[f10,x10,flo10,fup10] = ecdf(r_ajm);
figure
plot(x, f)
grid
title('Empirical CDF')
aaa1=smooth(dfdxs1)
aaa2=smooth(dfdxs2)
aaa3=smooth(dfdxs3)
aaa4=smooth(dfdxs4)
aaa5=smooth(dfdxs5)
aaa6=smooth(dfdxs6)
aaa7=smooth(dfdxs7)
aaa8=smooth(dfdxs8)
aaa9=smooth(dfdxs9)
aaa10=smooth(dfdxs10)
figure
plot(x1, aaa1)
plot(x2, aaa2)
plot(x3, aaa3)
plot(x4, aaa4)
plot(x5, aaa5)
plot(x6, aaa6)
plot(x7, aaa7)
plot(x8, aaa8)
plot(x9, aaa9)
plot(x10, aaa10) Star Strider on 8 Dec 2021
For data with an unknown distribution, I generally use the empirical cumulative distribution (ecdf) function to get the CDF, and the use the gradient function to derive the PDF. This is generally more robust than estimating the PDF directly, at least in my experience.
.
Andi on 30 Mar 2022
I try with the ksdensity but results are not expected.

### Categories

Find more on Half-Normal Distribution 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!