14.10.2014 Views

gnuplot documentation

gnuplot documentation

gnuplot documentation

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

55 HISTORY <strong>gnuplot</strong> 4.3 61<br />

good starting values. To find such, you can iterate several times, fitting only some of the parameters,<br />

until the values are close enough to the goal that the final fit to all parameters at once will work.<br />

Make sure that there is no mutual dependency among parameters of the function you are fitting. For<br />

example, don’t try to fit a*exp(x+b), because a*exp(x+b)=a*exp(b)*exp(x). Instead, fit either a*exp(x)<br />

or exp(x+b).<br />

A technical issue: the parameters must not be too different in magnitude. The larger the ratio of the<br />

largest and the smallest absolute parameter values, the slower the fit will converge. If the ratio is close<br />

to or above the inverse of the machine floating point precision, it may take next to forever to converge,<br />

or refuse to converge at all. You will have to adapt your function to avoid this, e.g., replace ’parameter’<br />

by ’1e9*parameter’ in the function definition, and divide the starting value by 1e9.<br />

If you can write your function as a linear combination of simple functions weighted by the parameters<br />

to be fitted, by all means do so. That helps a lot, because the problem is no longer nonlinear and should<br />

converge with only a small number of iterations, perhaps just one.<br />

Some prescriptions for analysing data, given in practical experimentation courses, may have you first<br />

fit some functions to your data, perhaps in a multi-step process of accounting for several aspects of<br />

the underlying theory one by one, and then extract the information you really wanted from the fitting<br />

parameters of those functions. With fit, this may often be done in one step by writing the model function<br />

directly in terms of the desired parameters. Transforming data can also quite often be avoided, though<br />

sometimes at the cost of a more difficult fit problem. If you think this contradicts the previous paragraph<br />

about simplifying the fit function, you are correct.<br />

A "singular matrix" message indicates that this implementation of the Marquardt-Levenberg algorithm<br />

can’t calculate parameter values for the next iteration. Try different starting values, writing the function<br />

in another form, or a simpler function.<br />

Finally, a nice quote from the manual of another fitting package (fudgit), that kind of summarizes all<br />

these issues: "Nonlinear fitting is an art!"<br />

54 Help<br />

The help command displays on-line help. To specify information on a particular topic use the syntax:<br />

help {}<br />

If is not specified, a short message is printed about <strong>gnuplot</strong>. After help for the requested<br />

topic is given, a menu of subtopics is given; help for a subtopic may be requested by typing its name,<br />

extending the help request. After that subtopic has been printed, the request may be extended again or<br />

you may go back one level to the previous topic. Eventually, the <strong>gnuplot</strong> command line will return.<br />

If a question mark (?) is given as the topic, the list of topics currently available is printed on the screen.<br />

55 History<br />

history command lists or saves previous entries in the history of the command line editing, or executes<br />

an entry.<br />

Here you find ’usage by examples’:<br />

history<br />

# show the complete history<br />

history 5<br />

# show last 5 entries in the history<br />

history quiet 5 # show last 5 entries without entry numbers<br />

history "hist.gp" # write the complete history to file hist.gp<br />

history "hist.gp" append # append the complete history to file hist.gp<br />

history 10 "hist.gp" # write last 10 commands to file hist.gp<br />

history 10 "|head -5 >>diary.gp" # write 5 history commands using pipe<br />

history ?load # show all history entries starting with "load"<br />

history ?"set c" # like above, several words enclosed in quotes

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!