## Fitting is an art: some general remarks

Fitting data is in most cases not a straightforward procedure and requires a lot of experience and intuition. Even the fitting of a Gaussian to some experimental data is sometimes difficult and the available algorithms fail, if the initial stepwidths or starting values are not chosen with some care. This rule holds even more for complex non linear fitting in a large parameter space. In many cases a simple theoretical model is used and it is not clear at the beginning if this model is able to describe the data at all. So how can reasonable starting parameters be found ? What value for the statistical temperature has to be chosen ?

One possible way to attack this problem is to monitor the status of a fit by viewing online its quality when fitting. The value of sta which is put onto the screen together with the standard deviation is only a very rudimentary information. In most cases it is necessary to view the data which is to be fitted graphically and see how the calculated data matches. It is also advisable to monitor the standard deviation and how it changes with time. After starting the fit it should the be possible to judge, if stepwidths should be modified or if the parameter range was chosen too small or too large etc.

To view online the contents of a file which contains data in column format the program display can be used. To start the display of the file data.dat with x-axis data in column 1 and y-axis data in column 2 just type (java has to be installed in order to use this):

display 1 2 data.dat

In order to send this data display to the background type under Linux:

display 1 2 data.dat &

and under windows:

start display 1 2 data.dat

Exercises:

• Start the fit example given for the fitting of the magnetic excitations of CeCu in mcphas/examples/cecu2a/fit. First copy the file mcphas.jjj.sav to mcphas.jjj Then start the fit by typing simannfit 10 mcphas.jjj.
• Stop the fit by editing calcsta as described above.
• Copy mcphas.jjj.fit to mcphas.jjj and type calcsta. What is the standard-deviation ?
• In order to fit crystal field parameters to transition energies of neutron intensities write a module calcsta for CeCu which uses only the program cfield to calculate the transition matrix elements and compare them to experimental data. The section 18 contains some further programs which might help.

Martin Rotter 2017-01-10