Deriving PDF from a given signal without using the hist() function?
15 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello,
I'm newbie at this and am enjoyably although a bit painfully trying to work my way around Matlab. As my question implies I have a signal and I would like to derive it's PDF function numerically without using the hist () function ? I looked in the documentation that it would be:
p1=pdf('name',X,A) or extra B,C depending if we have 1 or three parameters. Although I read the documentation I don't understand what X stands for (what I should replace it with?). From what I understand if it's for example normal pdf it would be:
p1=(pdf('name', X, A, B), being A the mean and B the standart derivation and X I don't know. I really don't understand how do I relate the pdf function with the signal I generated on matlab???
Hope I'm making sense and someone is able to help.
Thank you very much
Catarina
0 comentarios
Respuesta aceptada
bym
el 29 de Dic. de 2011
I am not sure I understand, but take a look at:
doc ksdensity
2 comentarios
David Young
el 30 de Dic. de 2011
catarina: I'm very puzzled. If you can't use hist(), how is that ksdensity() is a good solution?
Más respuestas (2)
David Young
el 29 de Dic. de 2011
The pdf function is not useful for this. It generates the theoretical PDF for a named distribution, but does not estimate an empirical PDF from data.
You are probably being asked to write code that does what hist does. This involves taking each element of the signal vector, working out the index of the bin it falls into, and incrementing an element of a histogram vector. To get an estimated PDF, you'd finally normalise the counts in the histogram vector.
You can do this with loops, or using MATLAB's vectorised style of programming. The essential ideas are the same in both cases, but vectorised code is more compact and often somewhat more efficient.
5 comentarios
Walter Roberson
el 27 de En. de 2012
No point debugging this in two Questions. See the answer in your newer Question on this point, http://www.mathworks.com/matlabcentral/answers/27188-estimating-pdf-numerically-without-using-hist-function
Peter Perkins
el 29 de Dic. de 2011
Catarina, the pdf function (I assume this is the one in the Statistics Toolbox) evaluates a known PDF at a set of points. That isn't what you want, at least initially.
If you have a set of data, then I think what you're asking for is a way to estimate their PDF. For a normal distribution, that's the normfit function, for other distributions there are other corresponding functions. Once, you have estimated the parameters of the distribution you want to use, then you can use the pdf function to plot the PDF over some range. There is also the ksdensity function, which creates a non-parametric estimate.
You might find it easier to use the fitdist function, and even easier still to use dfittool, which lets you do all this using a GUI.
Hope this helps.
3 comentarios
David Young
el 30 de Dic. de 2011
Peter: I suspect the fact that hist() is mentioned is an indication that the empirical PDF based on the histogram is required, not a fit to a specific model. Since hist() is forbidden, and the object is to become familiar with MATLAB rather than analyse some real data, I doubt that ksdensity() will be the right kind of answer.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!