pause -1 "first plotting the pure data set  (-> return)"

plot 'lcdemo.dat'
set xlabel "Temperature T  [deg Cels.]"
set ylabel "Density [g/cm3]"

pause 0 "now fitting a straight line to the data :-)"
pause 0 "only as a demo without physical meaning"
load 'line.fnc'
y0 = 0.0
m = 0.0
show variables
pause -1 "first a plot with all parameters set to zero  (-> return)"
plot 'lcdemo.dat', l(x)
pause -1 "now start fitting...  (-> return)"
fit l(x) 'lcdemo.dat' via y0, m
pause -1 "now look at the result (-> return)"
plot 'lcdemo.dat', l(x)

pause -1 "see the influence of weights for single data points   (-> return)"
fit l(x) 'lcdemo.dat' using 1:2:3 via y0, m
pause -1 "now look at the result (-> return)"
plot 'lcdemo.dat', l(x)

pause -1 "now prefer the high temperature data   (-> return)"
fit l(x) 'lcdemo.dat' using 1:2:4 via y0, m
pause -1 "now look at the result (-> return)"
plot 'lcdemo.dat', l(x)

pause  0 "now use real single-measurement errors to reach such a result (-> return)"
pause  0 "(look at the file lcdemo.dat and compare the columns to see the difference)"
pause -1 "(-> return)"
plot 'lcdemo.dat' using 1:2:5 with errorbars
fit l(x) 'lcdemo.dat' using 1:2:5 via y0, m
pause -1 "now look at the result (-> return)"
plot 'lcdemo.dat' using 1:2:5 with errorbars, l(x)

pause 0 "It's time now to try a more realistic model function"
load 'density.fnc'
show functions
pause 0 "density(x) is a function which shall fit the whole temperature"
pause 0 "range using a ?: expression. It contains 6 model parameters which
pause 0 "will all be varied. Now take the start parameters out of the"
pause -1 "file 'start.par' and plot the function    (-> return)"
load 'start.par'
plot 'lcdemo.dat', density(x)
fit density(x) 'lcdemo.dat' 'start.par'
pause -1 "now look at the result (-> return)"
plot 'lcdemo.dat', density(x)

pause 0  "looks already rather nice? We will do now the following: set"
pause 0  "the epsilon limit higher so that we need more iteration steps"
pause 0  "to convergence. During fitting please hit a key. You will be asked"
pause 0  "Stop, Continue, Execute: Try everything. There is a script"
pause 0  "defined which will plot the function with the actual parameter"
pause -1  "set.     (-> return)"
FIT_LIMIT = 1e-10
fit density(x) 'lcdemo.dat' 'start.par'
pause -1 "now look at the result (-> return)"
plot 'lcdemo.dat', density(x)
pause 0  "You can have a look at all previous fit results by looking into"
pause 0  "the file 'fit.log' or whatever you defined the env-variable 'FIT_LOGFILE'."
pause 0  "Remember that this file will always be appended, so remove it"
pause 0  "from time to time!"
