繁体   English   中英

如何计算拟合函数的p值?

[英]How to compute p value for my fitting function?

我已经在我的数据中加入了3高斯函数的混合,它非常适合。 我的问题是拟合在数值上的定义。 这可以通过p值定义。 如果是,那么我如何从拟合函数本身计算出来。

   g = fittype( @(c1,c2,p5,p6,p3,p4,p1,p2, x) (c1)*(1/(p6*sqrt(2*pi)))*exp(-((x-p5).^2)./(2*(p6.^2))) + ...
   (c2)*(1/(p4*sqrt(2*pi)))*exp(-((x-p3).^2)./(2*(p4.^2))) + ...
    (1-c1-c2)*(1/(p2*sqrt(2*pi)))*exp(-((x-p1).^2)./(2*(p2.^2)))       );

 %xr and yr is data (basically normalized histogram) 
[fE,GE,O] = fit(xr',yr',g,'StartPoint',startingVals);

%O gives me following quantity. 
        numobs: 50
         numparam: 8
    residuals: [50×1 double]
     Jacobian: [50×8 double]
     exitflag: 3
firstorderopt: 7.763960157882235e-04
   iterations: 24
    funcCount: 225
 cgiterations: 0
    algorithm: 'trust-region-reflective'
     stepsize: 0.002272922321389
      message: 'Success, but fitting stopped because change in residual…'

这里没有p值。 如何计算,谢谢。

您可以使用corrcoef函数查看matlab文档

基本上,如果您有数据y ,以及拟合函数Y的预测数据,您只需:

[R,p] = corrcoef(y, Y);

这将为您提供R值,以及高斯拟合后数据与预测数据之间相关性的p值,因此基本上您的拟合程度如何。

yY必须对应相同的输入值:

假设f是数据的“函数”。 它验证y = f(x) ,(对于x每个值,你有一个测量y )。

那么你必须有Y = f_fitted(x) ,其中f_fitted是你所适合的高斯函数。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM