Fitting sigmoid to data

前端 未结 3 1649
后悔当初
后悔当初 2021-02-04 12:24

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 sigmo

相关标签:
3条回答
  • 2021-02-04 13:06

    nlinfit, and especially gatool, are big hammers for this problem. A sigmoid is not a specific function. Most commonly it is taken to be the same as the logistic function (also often the most efficient to calculate):

    y = 1./(1+exp(-x));
    

    or a generalized logistic. But all manner of curves can have sigmoidal shapes. If you know if your data corresponds to one in particular, fitting can be improved and more efficient methods can be applied. For example, the error function (erf) has a sigmoidal shape and shows up in the CDF of the normal distribution. If you know that your data is the result of a Gaussian process (i.e., the data is the CDF) and you have the Stats toolbox, you can use the normfit function. This function is based on maximum likelihood estimation (MLE). If you end up needing to write a custom fitting function - say, for performance reasons - I'd investigate MLE techniques for the particular form of sigmoid that you'd like to fit.

    0 讨论(0)
  • 2021-02-04 13:08

    I would suggest you use MATLAB's Global Optimization Toolbox, and in particular the Genetic Algorithm Solver, which you can use for your problem by optimizing (= finding the best fit for your data) the sigmoid function's parameters through genetic algorithm. It has a GUI that is easy to use.

    The Genetic Algorithm Solver's GUI, which you can call using gatool: enter image description here

    0 讨论(0)
  • 2021-02-04 13:11

    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);
    

    Here sigfunc is just an example for a sigmoid function, and A is the vector of the fitting coefficients.

    0 讨论(0)
提交回复
热议问题