Fitting tool for experimental data

Good morning,

I have a number of experimental samples

X= [x1, x2, …, xn]

Y = [y1, y2, …, yn]

and I would like to fit them with the following equation:

y = c1*x^c2 + c3

Could you suggest a tool to evaluate the coefficients c1, c2, c3?

Hello User1
This is a standard nonlinear regression problem, and some of them are difficult to solve.
Within Octave the tools provided are leasqr(), nonlin curvefit(), and fsolve(). They are in the Optimization toolbox.
I wrote a simple GUI, find it at Octave Information
or the linear GUI at https://andreasstahel.github.io/Octave/FitTool.m
the nonlinear GUI at https://andreasstahel.github.io/Octave/FitToolNL.m
and the (essential) documentaion at https://andreasstahel.github.io/Octave/CurveFit.pdf

In my very recent book (flagrant add, sorry) “Octave and MATLAB for Engineering Applications” by Springer in section 3.2 (starting on page 219) find extensive documentaion about linear and nonlinear regression

I hope this helps
Andreas Stahel

P.S. If you send me your data I give it a try. andreas.stahel@gmx.com

Dear Dr Stahel,

Thank you for your reply.

I would appreciate it if you could have a look at my data.

Regards.

samples.m (910 Bytes)

Sometimes fminsearch in core can also be useful.

Enclosed my solution, using your data.
The comments in the code describe the path to the solution.
I use a local version of leasqr.m, since the one in the package optim
has a problem.

I hope it helps

Andreas

dfdp.m (2.6 KB)
leasqr.m (11.5 KB)
samples.m (1.6 KB)

Hello again

Ooops, the version in the optim package works, it is just using function handles.
Enclosed a version to use either leasqr() or nonlin_curvefit(), both from the optim package.

Andreas
samples.m (2.1 KB)

2 Likes

Dear Dr Stahel,

The file samples.m works perfectly.

Thank you for having suggested a new equation to fit the data.

Regards

Thank mmuetzel for your advice

@AndreasStahel: Thank you for your expertise and willingness to help @User1.

I see in your page Octave Information that you’re linking to the Octave Forge package collection at SourceForge. You may be aware that it has now been superseded by the much larger Octave package collection on Github itself. Could you add a link to that pls? GNU Octave - Packages

Background: Welcome Octave Packages!

1 Like

Hello Arun

Thank you for the constructive hint.
I will add a link to the github package collection.

Andreas

1 Like

I also tried fitting your data to 2 exponential equations.
samples3.m (1.4 KB)

It did not do a very good fit but you might like it anyway.

Thanks Dastew.