如何从正态概率密度函数中提取拟合数据 [英] How to extract fitted data from normal probability density function
问题描述
如果我用正态分布拟合单变量数据,如何在MATLAB中取回拟合值. 我正在使用这个简单的例子
If I fit a uni-variate data with normal distribution, how can i get back the fitted values in MATLAB. I am using this simple example
load hospital % data
x = hospital.Weight;
[mu sigma]=normfit(x) %normal fitting
%To visualize the pdf
xval=min(x):0.1:max(x)
yval=normpdf(xval,mu,sigma)
plot(xval,yval)
yval给出xval值的概率.现在,如果我想用上述正态分布近似提取出"x"的拟合值,该怎么做?从图片中可以看出,y轴值为pdf,位于0和1之间,但是我希望从遵循正态分布的数据中获得相应的拟合值.
yval is giving the probabilities of xval values. Now, If I would like to extract the fitted values of 'x' after approximating it with the above normal distribution, how do I do that?. As can be seen in the picture the y-axis values are the pdf and lies between 0 and 1, however I want the corresponding fitted values from the data that follows normal distribution.
拟合值是否为x_fitted = yval * sigma + mu?我想我这里缺少一些基本的数学知识.
Would the fitted values be x_fitted = yval*sigma + mu? !I think I am missing some basic maths here.
推荐答案
normfit
只是为您提供了适合的普通pdf的mu
和sigma
.从这些文件中,您可以使用normpdf
构建该pdf.因此,输入x
所需的y
值应为
normfit
simply gives you the mu
and sigma
of the fitted normal pdf. From those you build that pdf with normpdf
. So the desired y
values for your input x
would be
y = normpdf(x,mu,sigma)
您可以用它绘制的
hold on
plot(x,y,'ro')
请注意,通过此过程,即使数据实际上未遵循正态分布,数据也恰好位于正态pdf上.
Note that, with this procedure, the data lie exactly on the normal pdf, even if those data do not actually follow a normal distribution.
这篇关于如何从正态概率密度函数中提取拟合数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!