Empirical probability density function

I have a vector with 200.000 simulated values. I want to plot an empirical probability density function using this vector, but i have no idea how to do it. Can anybody help?

댓글 수: 1

Oleg Komarov
Oleg Komarov 2012년 5월 27일
Useful thread http://www.mathworks.com.au/matlabcentral/newsreader/view_thread/308951

댓글을 달려면 로그인하십시오.

답변 (1개)

the cyclist
the cyclist 2012년 5월 27일

0 개 추천

If you have the Statistics Toolbox, try the ksdensity() function.
>> doc ksdensity

댓글 수: 5

Martin
Martin 2012년 5월 27일
Yes, thank you, but i have tried it, and I need a 100% empirical distribution function. Now i have just made this
plot(hist(x)/length(x),'b');
I guess it works... but now i have problems with the x-axis. It just writes the interval from 1-10 on the axis. Do you know how to make matlab use the real values like it does when i plot hist(x)?
I am new to this, so maybe it's a stupid question, but i can't figure it out
Tom Lane
Tom Lane 2012년 5월 27일
Type "help hist" and you will see that the function returns two outputs, and you can plot one against the other. You'll need to normalize the first output by length(x)*binwidth where binwidth is the width of a bin (histogram bar).
Image Analyst
Image Analyst 2012년 5월 27일
Martin, well, how many bins do you want? If you want more than 10, then specify that. Then take both outputs of hist and plot them against each other, like Tom said. Or you might want to use histc() instead of hist(). For example
[counts binCenters] = hist(yourData, 256); % Use 256 bins.
plot(binCenters, counts);
Here's what it says in the help: "[n,xout] = hist(...) returns vectors n and xout containing the frequency counts and the bin locations. You can use bar(xout,n) to plot the histogram."
the cyclist
the cyclist 2012년 5월 28일
Martin,
I understand your desire for "100% empirical", but don't fool yourself that the hist() function isn't also imposing some of its own theoretical constructs. It is.
In the end, you are finding a statistical estimator to the "true" probability density function, and the important thing is to understand what you plan to do with the result, and what are the strengths and weaknesses of the choices of estimator. I am not an expert on this, so can't help you much. But of course the web abounds with references. Here is one I found: http://www.stat.ufl.edu/~rrandles/sta6934/smhandout.pdf. Caveat emptor.
the cyclist
the cyclist 2012년 5월 28일
Here is a more surfable version of the same content, that I discovered just after I added the prior comment:
http://ned.ipac.caltech.edu/level5/March02/Silverman/Silver_contents.html

댓글을 달려면 로그인하십시오.

질문:

2012년 5월 27일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by