how to make a pdf(probability density function) plot from a cdf(cumulative distributive function) plot?
27 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a CDF data and plot: my vector is 'on'
CDF_on = ecdf(on);
figure
ecdf(on)
i would like to get a pdf plot from this. i know that pdf values are derivative of cdf values. I try to do this way:
PDF_on=diff(CDF_on);
figure
plot(PDF_on,'-*')
derivative is good I think, but there is something wrong with x axis. My values on PDF plot are supposed to match the values on CDF plot but they dont. Please help? Thanks guys
0 commentaires
Réponses (1)
Star Strider
le 9 Avr 2014
Modifié(e) : Star Strider
le 9 Avr 2014
Try this:
PDF_on=diff([0 CDF_on]); % CDF_on is a row vector
or
PDF_on=diff([0; CDF_on]); % CDF_on is a column vector
Padding with the initial zero preserves the first element and makes the array sizes of PDF_on and CDF_on equal.
EDIT -- If you want PDF_on as d( CDF_on ) / d(x), do the same diff operation on the x vector, then do an element-by-element divide:
dfdx = diff([0 f]) ./ diff([0 x]);
0 commentaires
Voir également
Catégories
En savoir plus sur Annotations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!