.. _user_guide.fit:

============
Fitting data
============

The picture gives an example of dialog to setup and start fits.
First, there is the possibiity to fit different functions, called models to differentiate from the functions inside each
model, to different data simultaneously.
In the given example, two models were would be used during fit:
test1 and test3 use the default model, in this case model a,
while test2 uses model b.

In the middle column, the functions of model a are currently given in a tree structure:
It is comprised of three functions: a constant, a sine curve, which is a child of the constant, and free diffusion.
Functions can be dragged by mouse to each position, including a child position, and it is possible to switch between the
four basic arithmetic operations (+, -, \*, /) by striking the corresponding key.
Function at the same level, e.g., constant and free diffusion, are evaluated in the given order.
Children of a function take precedence over the following functions.
This means for the given example, that model a is something like

.. math::
    f(x) = [\text{constant} / \text{sine}] + \text{diffusion}

It is possible to skip functions by de-selecting it.
This choice alse affects children, even if they are selected.

The right column gives access to the parameter of selected function, in this case of the free diffusion function.
Here, the parameter :math:`M_0` is linked to the parameter :math:`C` of another constant function of model b
(identifiable by the number behind the name).
Linkage links not only parameter between function but all settings, e.g., if :math:`C` is fixed, :math:`M_0` is fixed.
Some parameters like gradient :math:`g` are predefined as fixed parameters and are lacking any options besides their value.
Upper and lower bounds may be given.
If one or two of the bounds are not given, this parameter is unbounded on the respective side.

If a parameter has one entry, this value is initial parameter for all data sets.
If the number of entries is greater than the number of data sets, the first :math:`n` values are used.
Here, test1 uses 1 as parameter for :math:`t_{ev}` and test3 uses 3.
If the number of entries is less than the number of data sets, the last value will be used for each additional set.