General Minimiser Utilities#

General utilities used by the minimisers.

minimisers.generalUtils.getFittedPriors(paramNames, priorNames, priorValues, fitLimits)#

Convert RAT prior information into an array.

Parameters:
  • paramNames (array) – The name of each parameter in the list.

  • priorNames (array) – The name of the prior for each parameter (‘uniform’, ‘gaussian’, or ‘jeffreys’)

  • priorValues (array) – The values for the prior (mu/sigma for Gaussian, unused otherwise)

  • fitLimits (array) – The lower and upper limits for each parameter.

Returns:

priorFitList – a length(paramNames)x5 array, where each row is the index of the parameter, a numeric flag for the prior, the prior values, and the limits for each parameter.

Return type:

array

minimisers.generalUtils.makeCell(m, n, vals)#

Creates a m by n cell array and initialise each cell with the given value.

Parameters:
  • m (int) – The dimension of the array.

  • n (int) – The dimension of the array.

  • vals (array) – The values to fill the cell array with.

Returns:

x – The required cell array.

Return type:

array

Examples

>>> array = makeCell(5, 2, [1, 1])
minimisers.generalUtils.makeEmptyBayesResultsStruct(nContrasts, isDomains, nChains)#

A function to make an empty container to hold the results of a Bayesian calculation.

Parameters:
  • nContrasts (int) – The number of contrasts.

  • isDomains (bool) – Whether the calculation is a domains calculation.

  • nChains (int) – The number of chains in the calculation.

Returns:

bayesResults – A struct with the following fields:

  • predictionIntervals: [1×1 struct]

  • confidenceIntervals: [1×1 struct]

  • dreamParams: [1×1 struct]

  • dreamOutput: [1×1 struct]

  • nestedSamplerOutput: [1×1 struct]

  • chain: [array of double]

Return type:

struct

minimisers.generalUtils.packParams(problemStruct, limits)#

Pack the parameters into an array of those being fitted.

Parameters:
  • problemStruct (struct) – The project struct.

  • limits (struct) – The limits for each parameter.

Returns:

  • problemStruct (struct) – The project struct with fit information.

  • fitNames (array) – The names of the parameters being fit.

minimisers.generalUtils.packParamsPriors(problemStruct, limits, priors)#

Pack the parameters into an array of those being fitted.

Parameters:
  • problemStruct (struct) – The project struct.

  • problemLimits (struct) – The limits for each parameter.

  • priors (array) – The priors of each parameter.

Returns:

  • problemStruct (struct) – The project struct with fit information.

  • fitNames (array) – The names of the parameters being fit.

  • fitPriors (array) – The priors of each fit parameter.

minimisers.generalUtils.unpackParams(problemStruct)#

Unpack params out of fitParams and back into problem.params.

Parameters:

problemStruct (struct) – The project struct.

Returns:

problemStruct – The project struct with unpacked fit information.

Return type:

struct

minimisers.generalUtils.bayesStats.percentileConfidenceIntervals(chain)#

Calculate percentile confidence intervals for a chain.

Parameters:

chain (array) – The chain from an MCMC calculation.

Returns:

confidenceIntervals – The mean and the 65% and 95% confidence intervals for the chain.

Return type:

array

minimisers.generalUtils.bayesStats.processBayes(bayesOutputs, problemStruct, controls)#

Process the output of a Bayesian optimisation.

Parameters:
  • bayesOutputs (struct) – The outputs of the Bayesian optimisation.

  • problemStruct (struct) – The struct for the project.

  • controls (struct) – The struct for the controls.

Returns:

  • problemStruct (struct) – The struct for the output project.

  • result (struct) – The results object from the optimisation.

  • bayesResults (struct) – The Bayesian-specific results from the optimisation.

minimisers.generalUtils.bayesStats.refPercentileConfidenceIntervals(bayesOutputs, problemStruct, controls, results)#

Calculate the percentile confidence intervals for the reflectivity.

Parameters:
  • bayesOutputs (struct) – The outputs of the Bayesian optimisation.

  • problemStruct (struct) – The struct for the project.

  • controls (struct) – The struct for the controls.

  • results (struct) – The results object from the optimisation.

Returns:

allPredInts – The prediction intervals from the optimisation.

Return type:

array