### Fitting reflectometry data

In this example we will fit synthetic reflectometry data generated with GenX.

The only fitting parameter of the simulation considered here is the thickness of the Ti layers. The reference data was obtained under the following assumptions:

• All Ti layers have the same thickness
• Thickness value was $3 , nm$

The fit view produced by running the fitting script is shown in the picture. The right-hand part of the view contains information about the current iteration of the fitting process, the maximum relative difference $d_{r, max}$ between the reference and the simulated data, and the current values of the fitting parameters.

One should note that in the current example the BornAgain built-in fitting engine and default minimizer (namely, Minuit) was used to fit the data.

The minimizer can be selected by the setMinimizer command:

minimizer = ba.Minimizer()
minimizer.setMinimizer("Genetic", "", "MaxIterations=30")

This code snippet replaces the default Minuit minimizer with the Genetic one, which is recommended to use for complicated multi-dimensional fitting tasks.

### Further topics

A much more sophisticated example of fitting experimental reflectometry data with BornAgain and an external minimizer can be found in Examples/fit/specular/RealLifeReflectometryFitting.py in the BornAgain directory.