% generate some random data
X1 = 10 + randn(100,1);
X2 = 15 + 2*randn(75,1);
X3 = 25 + 3*randn(125,1);
X = vertcat(X1,X2,X3);
% use a kernel smoother to model X
foo = fitdist(X,'kernel')
% inspect the methods of foo
methods(foo)
% Plot the pdf of foo
range = linspace(min(X), max(X), 100);
bar = pdf(foo, range)
plot(range, bar)
Here is an example that uses a kernel smoother. (Just in case you don't know what distribution describes your data sample)
% generate some random data
X1 = 10 + randn(100,1);
X2 = 15 + 2*randn(75,1);
X3 = 25 + 3*randn(125,1);
X = vertcat(X1,X2,X3);
% use a kernel smoother to model X
foo = fitdist(X,'kernel')
% inspect the methods of foo
methods(foo)
% Plot the pdf of foo
range = linspace(min(X), max(X), 100);
bar = pdf(foo, range)
plot(range, bar)
发布评论
评论(2)
如果您有 PDF 方程,您可以简单地将其绘制为指定的 x 值。例如,
正态分布
对数正态分布
您可以改变
sigma
、mu
和x 根据您的需要。对数正态分布是针对
x>0
定义的。If you have the equation to the PDF, you can simply plot it for specified values of x. For example,
Normal distribution
Log-Normal distribution
You can vary
sigma
,mu
andx
according to your needs. The log-normal distribution is defined forx>0
.这是一个使用内核平滑器的示例。 (以防万一您不知道什么分布描述了您的数据样本)
Here is an example that uses a kernel smoother. (Just in case you don't know what distribution describes your data sample)