Chris
Chris

Reputation: 1112

Fitting a function to a set of data with gnuplot

Sorry if I'm asking a stupid question here, but I'm a real noob concerning gnuplot so please be patient.

I have a set of data and tried to fit it with

       f(x)=a * cos(x-b)**2 via a,b. 

But it didn't work. It should look like this,

enter image description here

but it turned out like this enter image description here

What could be the Problem with my fit equation?

Upvotes: 0

Views: 741

Answers (1)

DerManu
DerManu

Reputation: 720

Your nonlinear fit converged to a local minimum, not the global one. You need to start fitting closer to the global minimum (which you as a human can find much more easily than a computer).

So you need to specify starting values for a and b that are closer to what you expect, via

a = ...

b = ...

before you call fit.

Have a look at this documentation section:

http://theochem.ki.ku.dk/on_line_docs/gnuplot/gnuplot_21.html#SEC77

Upvotes: 1

Related Questions