Subsections

## monte_carlo.error_analysis

### Synopsis

Calculate parameter errors from the Monte Carlo simulations.

### Defaults

monte_carlo.error_analysis()

### Description

Parameter errors are calculated as the standard deviation of the distribution of parameter values. This function should never be used if parameter values are obtained by minimisation and the simulation data are generated using the method `direct'. The reason is because only true Monte Carlo simulations can give the true parameter errors.

### Monte Carlo Simulation Overview

For proper error analysis using Monte Carlo simulations, a sequence of function calls is required for running the various simulation components. The steps necessary for implementing Monte Carlo simulations are:

1 -
The measured data set together with the corresponding error set should be loaded into relax.
2 -
Either minimisation is used to optimise the parameters of the chosen model, or a calculation is run.
3 -
To initialise and turn on Monte Carlo simulations, the number of simulations, n, needs to be set.
4 -
The simulation data needs to be created either by back calculation from the fully minimised model parameters from step 2 or by direct calculation when values are calculated rather than minimised. The error set is used to randomise each simulation data set by assuming Gaussian errors. This creates a synthetic data set for each Monte Carlo simulation.
5 -
Prior to minimisation of the parameters of each simulation, initial parameter estimates are required. These are taken as the optimised model parameters. An alternative is to use a grid search for each simulation to generate initial estimates, however this is extremely computationally expensive. For the case where values are calculated rather than minimised, this step should be skipped (although the results will be unaffected if this is accidentally run).
6 -
Each simulation requires minimisation or calculation. The same techniques as used in step 2, excluding the grid search when minimising, should be used for the simulations.
7 -
Failed simulations are removed using the techniques of model elimination.
8 -
The model parameter errors are calculated from the distribution of simulation parameters.

Monte Carlo simulations can be turned on or off using functions within this class. Once the function for setting up simulations has been called, simulations will be turned on. The effect of having simulations turned on is that the functions used for minimisation (grid search, minimise, etc) or calculation will only affect the simulation parameters and not the model parameters. By subsequently turning simulations off using the appropriate function, the functions used in minimisation will affect the model parameters and not the simulation parameters.

An example for model-free analysis using the prompt UI mode which includes only the functions required for implementing the above steps is:

```[numbers=none]
relax> minimise.grid_search(inc=11)                              # Step 2.
```

```[numbers=none]
relax> minimise.execute('newton')                                # Step 2.
```

```[numbers=none]
relax> monte_carlo.setup(number=500)                             # Step 3.
```

```[numbers=none]
relax> monte_carlo.create_data(method='back_calc')               # Step 4.
```

```[numbers=none]
relax> monte_carlo.initial_values()                              # Step 5.
```

```[numbers=none]
relax> minimise.execute('newton')                                # Step 6.
```

```[numbers=none]
relax> eliminate()                                               # Step 7.
```

```[numbers=none]
relax> monte_carlo.error_analysis()                              # Step 8.
```

An example for reduced spectral density mapping is:

```[numbers=none]
relax> minimise.calculate()                                      # Step 2.
```

```[numbers=none]
relax> monte_carlo.setup(number=500)                             # Step 3.
```

```[numbers=none]
relax> monte_carlo.create_data(method='back_calc')               # Step 4.
```

```[numbers=none]
relax> minimise.calculate()                                      # Step 6.
```

```[numbers=none]
relax> monte_carlo.error_analysis()                              # Step 8.
```

The relax user manual (PDF), created 2016-10-28.