How can I plot the probability density function of this generated cumulative distribution function curve?
Afficher commentaires plus anciens
I am writing code to generate a cumulative distribution function (CDF) curve. Now, I want to generate a probability density function (PDF) curve. Please help me create the PDF curve.
clc; clear all; close all;
m = 10^5;
A = 22;
A_T = 10^(A/10);
B = 5;
B_E = 10^(B/10);
exp = 3.5;
dt = 2;
t = dt^exp;
h = exprnd(1/t, [1, m]);
ee = 10^(110/10);
R1 = 4;
R2 = 5;
g_R = (2^R2) - 1;
g_E = (2^(R2-R1)) - 1;
n_2 = 1;
g_d = g_E / (1 + g_E);
x2= 0:1:100;
b = 1 + ((t/ee)*(B_E/A_T));
a = g_d/g_R;
for r = 1:length(x2)
c11= 0;
for it = 1:m
if 1/(a * ( b + (n_2 / ( A_T * h(1, it) ) ) ) ) < x2(r)
c11 = c11+1;
end
end
p1(r) = c11/m;
end
grid on
plot(x2,p1,'r');
Réponse acceptée
Plus de réponses (1)
Add these lines at the end of the script to visualize the estimated PDF using the gradient() method.
cdf = p1;
pdf = gradient(p1)./gradient(x2);
pdf = smoothdata(pdf, "sgolay", 5);
plot(x2, cdf), hold on
plot(x2, pdf), grid on
xlabel('x')
legend('CDF', 'PDF', 'location', 'east'), ylim([-0.2, 1.2])
Catégories
En savoir plus sur Exploration and Visualization dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

