将S形拟合到数据 [英] Fitting sigmoid to data
本文介绍了将S形拟合到数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有很多曲线拟合和插值工具,例如polyfit(甚至我发现的这个不错的logfit工具箱
There are many curve fitting and interpolation tools like polyfit (or even this nice logfit toolbox I found here), but I can't seem to find anything that will fit a sigmoid
function to my x-y data.
是否存在这样的工具,或者我需要自己制作一个工具?
Does such a tool exist or do I need to make my own?
推荐答案
如果安装了统计工具箱,则可以使用 nlinfit
:
If you have the Statistics Toolbox installed, you can use nonlinear regression with nlinfit
:
sigfunc = @(A, x)(A(1) ./ (A(2) + exp(-x)));
A0 = ones(size(A)); %// Initial values fed into the iterative algorithm
A_fit = nlinfit(x, y, sigfunc, A0);
这里sigfunc
只是一个S型函数的示例,而A
是拟合系数的向量.
Here sigfunc
is just an example for a sigmoid function, and A
is the vector of the fitting coefficients.
这篇关于将S形拟合到数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文