I have the following data which I am trying to fit a sigmoid function.... but I am not sure if the sigmoid function is the best fit for these type data - also I dont know which sigmoid function to use.
x = [ 10 160 352 544 736 928 1120 1312 1504]
y = [0 0 0.66 0.66 0.58 0.66 0.83 0.66 0.75]
any help will be of much appreciation!
Ana
Are you serious? Asking WHICH sigmoid applies here
is an impossible question.
Your data is constant at one level, then between the
second and third points, it moves to a second level.
There is no shape in that transition to estimate the
parameters of any meaningful sigmoid function,
certainly not given the degree of noise in your data.
Perhaps you should consider the ultimate sigmoid
function - the Heaviside step function. Nothing more
is justified by your data.
John
Are you serious? Asking WHICH sigmoid applies here
clear all, close all, clc
x = [ 10 160 352 544 736 928 1120 1312 1504]
t = [ 0 0 0.66 0.66 0.58 0.66 0.83 0.66 0.75]
a = mean(t(t>0)) % 0.6857
y0 = a*(x-x(2))/(x(3)-x(2))
x0 = x(2) + (x(3)-x(2))*a/2 % 225.8286
% Logarithmic Sigmoid
% logsig is in the neural network toolbox
% logsig(x) = exp(-x)./(1+exp(-x))
y = a*logsig(x-x0)
figure
hold on
plot(x,t,'k')
plot(x(2:3),y0(2:3),'g')
plot(x,y,'r')
% Naive constant model
y00 = mean(t) % 0.5333
e00 = (t-y00)
MSE00 = mean(e00(:).^2) % 0.0856 Mean-Squared-Error
% Logsig Model
e = (t-y)
MSE = mean(e(:).^2) % 0.0043
R2 = 1-MSE/MSE00 % 0.9497 R^2 statistic
% Not bad. Now see if you can find an optimal b for
%
% y = a*logsig((x-x0)/b)
%
% Compare with a least-squares fit for [a x0 b]
%
% Hope this helps.
%
% Greg
Thank you John for your feedback! Heaviside step function is not appropriate for my data - the data are for a psychophysic curve...
Ana