Deriving PDF from a given signal without using the hist() function?
6 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
bym
2011-12-29
I am not sure I understand, but take a look at:
doc ksdensity
2 个评论
David Young
2011-12-30
catarina: I'm very puzzled. If you can't use hist(), how is that ksdensity() is a good solution?
更多回答(2 个)
David Young
2011-12-29
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 个评论
Walter Roberson
2012-1-27
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
2011-12-29
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 个评论
David Young
2011-12-30
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.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!