RAT Entry Functions#

Once a project and controls class have been created, RAT is run via the RAT function:

Sample usage of RAT class.#
    % Initialize the project class
    problem = createProject();

    % Initialize the controls class
    controls = controlsClass();

    % call the RAT function
    [problem,results] = RAT(problem,controls);

The RAT function turns the projectClass and controlsClass into relevant structs and cell arrays.

The parseClassToStructs function converts the user-friendly data input into an object that can be passed to compiled code.

Then, the RATMain function redirects the control flow based on what procedure is selected in controlsClass.

API.RAT(project, controls)#

Runs RAT calculation for the given project and controls inputs.

Parameters:
  • project (projectClass) – An instance of the projectClass.

  • controls (controlsClass) – An instance of the controlsClass.

Returns:

  • project (projectClass) – An instance of the projectClass with updated fit values from the calculation.

  • result (struct) – The results of the calculation such as simulated reflectivities, SLD profiles etc.

Notes

For a non-Bayesian procedure, the result struct has the following fields below where nDomains, nContrasts and nParams are the the number of domains, contrasts and params respectively

Field

Type

Description

reflectivity

[nContrasts x 1] cell

calculated reflectivity values

simulation

[nContrasts x 1] cell

simulated reflectivity values

shiftedData

[nContrasts x 1] cell

Data shifted using given scale factor

backgrounds

[nContrasts x 1] cell

background values for each contrast

resolutions

[nContrasts x 1] cell

resolution values for each contrast

sldProfiles

[nContrasts x nDomains] cell

SLD profiles

layers

[nContrasts x nDomains] cell

layers parameter values for each contrast

resampledLayers

[nContrasts x nDomains] cell

resampled layer values for each contrast if resample is true otherwise an array of zeros

calculationResults

[1 x 1] struct

Chi-squared goodness of fit results. The fields are chiValues and sumChi

contrastParams

[1 x 1] struct

Parameter values for each contrast. The fields are scalefactors, bulkIn, bulkOut, subRoughs, and resample

fitParams

[1 x nParams] double

fitted parameter values

fitNames

[nParams x 1] cell

name of fitted parameters

For a Bayesian procedure, the result struct will also contain the following fields in addition to the ones above

Field

Type

Description

predictionIntervals

[1 x 1] struct

Mean, 65% and 95% confidence intervals, and chi squared goodness of fit values for the reflectivity and SLD. The fields are reflectivity, sld, and sampleChi.

confidenceIntervals

[1 x 1] struct

Confidence intervals for the Markov chain. The fields are percentile95, percentile65, and mean.

dreamParams

[1 x 1] struct

Parameters used to configure dream.

dreamOutput

[1 x 1] struct

Diagnostic output information from a DREAM run. The fields are allChains, outlierChains, runtime, iteration, modelOutput, AR, R_stat, and CR.

nestedSamplerOutput

[1 x 1] struct

Output from a nested sampler run. The fields are LogZ, LogZErr, nestSamples, and postSamples.

chain

[M x nParams] double

MCMC chains where M is the length of each chain.

API.RATMain(problemStruct, controls)#

Select and run the internal RAT procedure.

Parameters:
  • problemStruct (struct) – The project class in struct form (generated from parseClassToStructs)

  • controls (struct) – The controls struct (generated from parseClassToStructs)

Returns:

  • problemStruct (struct) – The output problem struct.

  • results (struct) – The calculation results.

  • bayesResults (struct) – Additional results from a Bayesian calculation.

API.parseClassToStructs(project, inputControls)#

Breaks up the classes into the relevant structures for inputting into C