【问题标题】:How to calculate mean of function in a gaussian fit?如何计算高斯拟合中的函数平均值?
【发布时间】:2017-04-15 04:09:37
【问题描述】:

我在 MATLAB 中使用曲线拟合应用程序。如果我理解正确,左框中的“b1”组件是函数的平均值,即y=50% 和我的x 数据为[-0.8 -0.7 -0.5 0 0.3 0.5 0.7]x 点,那么为什么这个例子中的这个数字这么大(第631章?

一般模型 Gauss1:

f(x) =  a1*exp(-((x-b1)/c1)^2)

系数(置信度为 95%):

   a1 =  3.862e+258  (-Inf, Inf)

   b1 =       631.2  (-1.117e+06, 1.119e+06)

   c1 =       25.83  (-2.287e+04, 2.292e+04)

【问题讨论】:

  • 也写入y数据
  • y= [0.2 0 0.2 0.2 0.5 1 1] 通过查看应用程序给我的图,我可以看到 50% 点介于 0.4 和 0.6 之间。我不知道如何从公式中计算出这个数字。

标签: matlab curve-fitting gaussian


【解决方案1】:

您的数据看起来像 cdf 而不是 pdf。您可以将此代码用于您的解决方案

xi=[-0.8,-0.7,-0.5, 0.0, 0.3, 0.5, 0.7];
yi= [0.2, 0.0, 0.2, 0.2, 0.5, 1.0, 1.0];
fun=@(v) normcdf(xi,v(1),v(2))-yi;
[v]=lsqnonlin(fun,[1,1]); %[1,2] 
mu=v(1); sigma=v(2);
x=linspace(-1.5,1.5,100);
y=normcdf(x,mu,sigma);
figure(1);clf;plot(xi,yi,'x',x,y);
annotation('textbox',[0.2,0.7,0.1,0.1], 'String',sprintf('mu=%f\nsigma=%f',mu,sigma),'FitBoxToText','on','FontSize',16);

你会得到:mu=0.24537, sigma=0.213

如果你仍然想适应 pdf,只需将 'fun'(和 'y')中的函数 'normcdf' 更改为 'normpdf'。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-04-05
    • 2017-09-26
    • 2014-10-25
    • 2021-02-14
    • 1970-01-01
    • 2012-07-15
    • 2017-06-11
    • 2015-04-23
    相关资源
    最近更新 更多