RAT Entry Functions#
The user should begin by creating a project and controls object, then the user can run RAT like shown below
% Initialize the project class
problem = createProject();
% Initialize the controls class
controls = controlsClass();
% call the RAT function
[problem,results] = RAT(problem,controls);
When the RAT function is called, the classes are passed into internal functions like parseClassToStructs which takes the classes and breaks them down into cells, limits, priors and more importantly converts the project class to struct.
Then, the RATMain function redirects the control flow based on what procedure is selected in controlsClass. One of the redirecting functions will call the reflectivityCalculation which starts the reflectivity calculation.
Some interesting data type changes are needed because of how things work with coder. Coder wont accept variable sized cell arrays contains variable sized arrays (strings for eg) in a field of a struct. So, look at parseClassToStructs function to understand how the data is converted.
- API.RAT(project, controls)#
Runs RAT calculation for the given project and controls inputs.
- Parameters:
project (
projectClass
) – An instance of theprojectClass
.controls (
controlsClass
) – An instance of thecontrolsClass
.
- 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
layerSlds
[nContrasts x nDomains] cell
layers parameter values for each contrast
sldProfiles
[nContrasts x nDomains] cell
SLD profiles
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
andsumChi
contrastParams
[1 x 1] struct
Parameter values for each contrast. The fields are
scalefactors
,bulkIn
,bulkOut
,subRoughs
, andresample
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
, andsampleChi
confidenceIntervals
[1 x 1] struct
Confidence intervals for the Markov chain. The fields are
percentile95
,percentile65
, andmean
.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
, andCR
nestedSamplerOutput
[1 x 1] struct
Output from a nested sampler run. The fields are
LogZ
,LogZErr
,nestSamples
, andpostSamples
chain
[M x nParams] double
MCMC chains where M is the length of each chain
- API.RATMain(problemStruct, problemLimits, controls, priors)#
- API.parseClassToStructs(project, inputControls)#
Breaks up the classes into the relevant structures for inputting into C