how to make a pdf(probability density function) plot from a cdf(cumulative distributive function) plot?
19 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Star Strider
el 9 de Abr. de 2014
Editada: Star Strider
el 9 de Abr. de 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 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!