#### Table of Contents

#####

1. Load data
2. Set additional parameters
3. Set real-space condition
4. Optimize background with DifEv
5. Fit results
6. Plot options

At the top of the Data Plot inset the "progress bar" is diplayed. Those parameters that have to be specified are shown in red. Once provided, they corresponding parameter labels turn green. Optional parameters are marked with grey.

Hover a mouse cursor over a plot to display coordinates of a point.

#### 1. Load data

BBEST supports text files, .csv-files, .sqa and .sqb-files, returned by PDFgetN, and .RData files that contain results of previous fits (as returned by 'Download fit results as .RData file'). For the text files, the data should be given in the following format

x | y | SB | sigma | lambda
0 | 2 | 4 | 6 | 8
1 | 3 | 5 | 7 | 9
... | ... | ... | ... | ...

Here SB (a coherent-scattering baseline SB(Q)), sigma (a noise level ε(Q)) and lambda (a useful signal level) columns are optional.

#### 2. Set additional parameters

Truncate data | in some cases it is necessary to remove unwanted data. For example, low-x regions can contain artifacts while high-x regions can be dominated by noise.

Useful signal level

the mean signal magnitude, lambda, is calculated as a linear piecewise function, which is equal to lambda_0 outside the [x.min,x.max] region. Inside this region, lambda is approximated by a line that connects points (x_1;lambda_1) and (x_2;lambda_2). An estimate of this parameter does not have to be accurate. lambda can be thought of as a function that crosses the midpoints of the signal peaks after background subtraction.

Baseline

neutron coherent-scattering baseline (SB) or any other baseline that has to be preserved in the experimental signal. For neutron total-scattering experiments, SB can be calculated as

SB(Q)=1-(1-L)ΣkNkfkexp(-1/2σkk2Q2)/N<f2>,

where Nk is the number of atoms of type k per unit cell, fk is the scattering factor for the atom k, <f2> is the average of the scattering length squared, σkk2 is the atomic displacement parameter (ADP), and L is the Laue term. If unknown, the APD(s) can be refined (to do this, a real-space condition should be specified).

Noise level

Although noise in diffraction experiments frequently obeys Poisson statistics, various corrections for background, absorption, multiple scattering, etc. can affect its behavior. We suggest considering the experimental uncertainty as having a Gaussian distribution with an x-dependent amplitude. Splitting the grid into n.regions segments and estimating the Gaussian standard deviation over these segments allows us to approximate the true noise distribution. You can specify the number of regions to be used (x-range is then split into n.regions equal regions), or, if noise can be considered as uniform, provide bounds for the peak-free region. BBEST estimates the noise level using aws package that implements adaptive weights smoothing for signal smoothing. "thresh.scale" argument can be used to tweak the threshold levels to vary the degree of smoothing. Indicate a single value or <number of regions> values, separated by commas.

P(bkg)

A probability for a single datapoint to contain contributions from the background and noise only. (1-P(bkg)) is the probability for a datapoint to contain also a signal contribution. P(bkg) can be thought of as a (total length of areas that contain only the background)/(total x-scale area). If this probability is over- or under-estimated, the background can also be over- or under-estimated, respectively. If you see that the estimated backround exhibits both types of such unwanted behavior (e.g., overestimated in one region and underestimated in another), try using the iterative procedure. It will estimate P(bkg) at each point separately (the fitting time will double).

G(r) | To calculate and plot G(r) prior to background fitting, indicate the bounds and spacing for the r-grid and press "Plot G(r)".

#### 3. Set real-space condition

For total scattering experiments, a real-space pair distribution function (PDF or G(r)), obtained as the Fourier transform of the total scattering function S(Q), exhibits a linear (or quasi-linear) dependence on r at distances smaller than the shortest interatomic distance in the material. Knowledge of the correct behavior of a PDF at low r can be used to constrain the optimization procedure.

Condition type | either a 'Gaussian noise' or a 'Correlated noise'. The r-space noise can be considered as independent or correlated Gaussian. For better computational stability we recommend using the 'Gaussian noise' option.
Number density of the material ρ0 | atomic number density of the material, which is the number of atoms in the unit cell divided by the unit-cell volume.
min(r), max(r), dr | bounds and spacing for a grid on which the PDF behaviour is constrained.

Use this function only after the noise level ε has been estimated.

#### 4. Optimize the background with DifEv

The posterior maximization is performed using the Differential Evolution Algorithm (DEA; Price et al., 2005) implemented in the DEoptim package.

Before starting the fit, indicate the following parameters:

Number of population members | NP, number of population members. For many problems, it is best to set NP to be at least 10 times the length of the parameter vector (which includes spline knot positions, and, optionally, the normalization and ADP parameters).
Number of iterations | itermax, the maximum iteration (population generation) allowed.
Crossover probability (CR) | a crossover probability from the interval [0,1]. The crossover probability CR controls the fraction of parameter values that are copied from the mutant.
Differential weighting factor (F) | differential weighting factor from interval [0,2]. Effective values are typically less than one.
Lower and upper bounds for the scale factor fit | bounds for the normalization parameter. If no normalization is needed, use the default value '1, 1'
Lower and upper bounds for background | estimates for the background minimum and maximum values. For faster convergence it is better to estimate the minimum lower and the maximum higher than their actual respective values.
Fit the background with | for fitting of individual-bank data we recommend using the six-parameter analytical function. For a (blended) total scattering function we recommend using splines. Estimation of the Uncertainty interval is unavailable for analytical backgrounds.
Number of splines or spline knot positions | a single integer number (N) will specify the number of spline functions to be used (N equidistant knots will be generated). To set specific knot positions, enter the corresponding numbers separated by commas. Select more knots for those regions that feature an oscillating background.

#### 5. Fit results

This inset enables download of the fitting results in a text format, as a correction .fix file for PDFgetN, or as a binary file that contains R-objects. The PDF can be calculated on a specified grid and downloaded as well. To view the corresponding plots, select 'Fit Results Plot' tab in the top tab panel.

The iterative algorithm is available if the fit has been performed using the G(r)-corrected Bayesian model and the background function was expanded in terms of splines. It includes the following steps:

1. Estimation of the background using Q-space Bayesian models
2. Calculation of the difference between the G(r) obtained using the two models for r<1Å
3. Conversion of this difference to Q-space and adding it to an estimate of the baseline SB
4. Minimization of the target function for the new G(r)-corrected model

The first and fourth steps can be performed using either the Gradient Descent Algorithm (GDA) or DEA. GDA could be faster but tends to converge to a local minimum. DEA, while slower, is much more robust. The control parameters used for DEA will be the same as used for the initial fit.

#### 6. Plot options

You can set x- and y-axis limits for a graph. If this option is used, the truncation procedure won't rescale the data plot automatically. Note, that choosing the plot name from the pulldown select list does not render the plot on the right panel. To do that, select the corresponding inset at the top.