3

我有一个 100x1 向量的数据。如何在 Matlab 中显示其经验 pdf?另外,如果我想在同一张图上比较三个向量的pdf,那么该怎么做呢?

现在我正在使用pdfplot.m文件来绘制我的经验 pdf,但是当我想通过使用“保持”来比较 3 个分布时,首先它不起作用,其次所有分布都是相同的颜色。谢谢!

编辑:我不想绘制 cdf。

4

2 回答 2

12

您正在寻找的是内核密度估计(也称为Parzen windows)。它在统计工具箱中的KSDENSITY函数中实现:

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

替代文字

上面的 Wikipedia 条目有一个使用FEX上的函数提交的 MATLAB 示例

于 2010-09-29T20:49:57.173 回答
4

历史

hist(data)

或者,如果您想更好地控制它的呈现方式,请使用:

[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
于 2010-09-29T18:36:37.060 回答