开发者

How can I display empirical pdf of my 100x1 vector data in Matlab?

I have a data which is 100x1 vector. How can 开发者_C百科I display its empirical pdf in Matlab? Also, if I want to compare the pdf of three vectors on the same graph, then how to do that?

Right now I am using pdfplot.m file to plot my empirical pdf, however when I want to compare the 3 distributions by using 'hold on', then firstly its not working and secondly all the distributions are in same color. Thanks!

EDIT: I don't want to plot cdf.


What you are looking for is Kernel density estimation (also known as Parzen windows). Its implemented in KSDENSITY function in the Statistics toolbox:

data = randn(100,1);
ksdensity(data)

How can I display empirical pdf of my 100x1 vector data in Matlab?

The Wikipedia entry above has a MATLAB example using a function submission on FEX


hist:

hist(data)

or, if you want more control over how it is presented, use:

[n,x] = hist(data);
plot(x,n,'rx-'); %# just an example, plot the pdf with red x's and a line, 
                 %# instead of bars
figure;
plot(x, cumsum(n)/sum(n)); %# plot the CDF
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜