The user must provide a program *calcsta* (under windows
it is *calcsta.bat*), which calculates the standard deviation
of some experimental data from model calculated data. This program can
be a bash script such as */mcphas/examples/cecu2a/fit/calcsta* or just a
very short program such as:

#!/usr/bin/perl # do a mcphase simulation. The measured magnetisation data must # be in directory ./fit/mcphas.fum column 11 12 13. # the program mcphas\index{mcphas} will compare measured data with calculated # data and generate an output such as sta=14.3112, which # contains the standard deviation system ("mcphas");

... in general the output of this batch (to stdout) must contain a line
such as *sta = 4122.32*, which contains the calculated standard
deviation which will be minimized by the fitting procedure.

Important notes:

- Before starting a fit it is necessary to test the program
*calcsta*by typing*./calcsta*. The calculation should run and there must appear an output the line*sta= ...*on the screen. If this works, a fit may be started. - the programs
*McPhas*and*McDisp*always try to calculate a standard deviation and write such*sta = ...*statement to stdout. So it is possible to use these programs to create the desired output. - Alternatively (or in addition)
any other program can be called in
*calcsta*and calculate the standard deviation*sta*. Useful programs are*chi2*,*rpvalue*. - Several () occurrencies of
*sta =*contribute additively to the variance , which is minimized in the process. - if
*sta=*is followed by two numbers and , the first is interpreted as the deviation from an experimental data point (which is to be fitted). The second number is interpreted as the squared errorbar of this datapoint. If is not given, the program minimizes the variance*sta*. If is given, the program minimizes . The error is used at the end of the fitting to calculate a covariance matrix, which can be used to estimate correlations and errors of the fitting parameters: , the covariance matrix is then , it's diagonal elements correspond to the squared error of the fitting parameters par and the off diagonal elements to the correlation among these fitting parameters. Useful to generate the required*sta= ...*statements is the program*chi2*. - note, that the program
*simannfit*calls the user written program*calcsta*with a number as argument, e.g. as*calcsta 21.3*. This number (i.e. 21.3 in our example) denotes a maximum value of the standard deviation. The user written program may use this number and stop, when in the summation process to obtain standard deviation*sta*reaches a value larger than this maximum number. Using this option is advisable in complex fitting problems in order to optimise the time of the fitting procedure. Note, that the module*mcphas*can be used with the option*-stamax 21.3*, which leads to a stop when the value of the standard deviation 21.3 is reached.

Martin Rotter 2017-01-10