Do you have Matlab?
If so, I have attached the necessary Matlab files to get the Matlab results, however if you dont I have also pasted the output of Matlab.
I think the problem is in the way that the function has been defined, but Im not sure. In Matlab the function is defined as the entire least squares equation, not just the right hand side of the levenberg equation.
Matlab function:
Code:
function sse=myfit(params,Input,Actual_Output)
a=params(1)
b=params(2)
c=params(3)
% c = c'
Fitted_Curve = (1/(a*b))*(c-asinh(sinh(c)*exp(a*Input*2*pi)));
Error_Vector=Actual_Output-Fitted_Curve ;
sse=sum(Error_Vector.^2);
The function above is then passed to Matlab's Levenberg Marquardt algorithm here:
Code:
Data = [1.2 2.693 4.325 6.131 8.125]%paper data
t = [1 2 3 4 5];
%%
Starting=[1, 1, -1];
options=optimset('Display','iter');
Estimates=fminsearch(@myfit,Starting,options,t,Data)
Estimates being the vector of the parameters returned which come out as
Estimates =
0.0250 1.8944 -0.3690
The Matlab code then plots the graph that would be the function with those parameters so the reader can see the quality of the fit to the original data (attached).
Matlab code:
Code:
Data = [1.2 2.693 4.325 6.131 8.125]%paper data
t = [1 2 3 4 5];
%%
Starting=[1, 1, -1];
options=optimset('Display','iter');
Estimates=fminsearch(@myfit,Starting,options,t,Data)
%%
a = Estimates(1)
b = Estimates(2)
c = Estimates(3)
tt = 0:0.001:5;
% To check the fit
% subplot(2,2,1)
plot(t,Data,'*')
hold on
plot(tt,(1/(a*b))*(c-asinh(sinh(c)*exp(a*tt*2*pi))),'r');
xlabel('goodness of fit graph');
and the code in the file "myfit.m"
Code:
function sse=myfit(params,Input,Actual_Output)
a=params(1)
b=params(2)
c=params(3)
% c = c'
Fitted_Curve = (1/(a*b))*(c-asinh(sinh(c)*exp(a*Input*2*pi)));
Error_Vector=Actual_Output-Fitted_Curve ;
sse=sum(Error_Vector.^2);
So I am confused as to why this algorihtm (the c one) produces such wildly different results...
Edit, the second graph is using the results that you got - the one that has a red "step change".