GaussianNonLinearCalibration

class GaussianNonLinearCalibration(*args)

Gaussian non linear calibration algorithm (3DVAR).

Parameters:
modelFunction

The parametric function to be calibrated.

inputObservations2-d sequence of float

The sample of input observations. Can have dimension 0 to specify no observations.

outputObservations2-d sequence of float

The sample of output observations.

parameterMeansequence of float

The mean of the Gaussian prior distribution of the parameter.

parameterCovariance2-d sequence of float

The covariance matrix of the Gaussian prior distribution of the parameter.

errorCovariance2-d sequence of float

The covariance matrix of the Gaussian distribution of the observations error.

Notes

This class implements the Maximum A Posteriori (MAP) estimator for a nonlinear model under the Bayesian hypothesis that the prior and the observation errors have Gaussian distributions. This algorithm is also known as 3DVAR.

The given observation error covariance can be either local, i.e. the same matrix applies for each observation and is of dimension the output dimension of the model, or global, i.e. the matrix describes the full set of observation errors, in which case its dimension is the product of the output dimension of the model and the number of observations.

The prior distribution of the parameter is Normal.

The posterior distribution of the parameter is also Normal.

Depending on the value of the GaussianNonLinearCalibration-BootstrapSize key in the ResourceMap, the parameters are estimated differently.

  • If GaussianNonLinearCalibration-BootstrapSize is set to a nonzero positive integer, then a bootstrap resampling of the observations is performed and the posterior distribution is based on a KernelSmoothing of the sample of boostrap optimum parameters.

  • If GaussianNonLinearCalibration-BootstrapSize is set to zero, then the posterior distribution is evaluated based on a linear approximation of the model at the optimum. This corresponds to using GaussianLinearCalibration at the optimum, and is named Laplace approximation in the Bayesian context.

The default value of GaussianNonLinearCalibration-BootstrapSize is nonzero, meaning that a bootstrap is used by default. This can be costly in some practical use cases, because it requires several runs of the optimization algorithm. In this case, please set the bootstrap size to zero.

The resulting error distribution is Normal with a mean estimated from the sample mean of the residuals and with a covariance matrix equal to the errorCovariance input argument.

Please read read Gaussian calibration for more details on Gaussian calibration.

Examples

Calibrate a nonlinear model using 3DVAR:

>>> import openturns as ot
>>> ot.RandomGenerator.SetSeed(0)
>>> m = 10
>>> x = [[0.5 + i] for i in range(m)]
>>> inVars = ['a', 'b', 'c', 'x']
>>> formulas = ['a + b * exp(c * x)']
>>> model = ot.SymbolicFunction(inVars, formulas)
>>> p_ref = [2.8, 1.2, 0.5]
>>> params = [0, 1, 2]
>>> modelX = ot.ParametricFunction(model, params, p_ref)
>>> y = modelX(x)
>>> y += ot.Normal(0.0, 0.05).getSample(m)
>>> parameterMean = [1.0]*3
>>> priorCovariance = ot.CovarianceMatrix(3)
>>> errorCovariance = ot.CovarianceMatrix(1, [0.1])
>>> algo = ot.GaussianNonLinearCalibration(modelX, x, y, parameterMean, priorCovariance, errorCovariance)
>>> algo.run()
>>> print(algo.getResult().getParameterMAP())
[2.705...,1.212...,0.499...]

Methods

getBootstrapSize()

Accessor to the bootstrap size used to sample the posterior distribution.

getClassName()

Accessor to the object's name.

getErrorCovariance()

Accessor to the observation error covariance.

getGlobalErrorCovariance()

Accessor to the flag for a global observation error covariance.

getId()

Accessor to the object's id.

getInputObservations()

Accessor to the input data to be fitted.

getModel()

Accessor to the model to be fitted.

getName()

Accessor to the object's name.

getOptimizationAlgorithm()

Accessor to the optimization algorithm used for the computation.

getOutputObservations()

Accessor to the output data to be fitted.

getParameterCovariance()

Accessor to the parameter prior covariance.

getParameterMean()

Accessor to the parameter parameterMean.

getParameterPrior()

Accessor to the parameter prior distribution.

getResult()

Get the result structure.

getShadowedId()

Accessor to the object's shadowed id.

getVisibility()

Accessor to the object's visibility state.

hasName()

Test if the object is named.

hasVisibleName()

Test if the object has a distinguishable name.

run(*args)

Launch the algorithm.

setBootstrapSize(bootstrapSize)

Accessor to the bootstrap size used to sample the posterior distribution.

setName(name)

Accessor to the object's name.

setOptimizationAlgorithm(algorithm)

Accessor to the optimization algorithm used for the computation.

setResult(result)

Accessor to optimization result.

setShadowedId(id)

Accessor to the object's shadowed id.

setVisibility(visible)

Accessor to the object's visibility state.

__init__(*args)
getBootstrapSize()

Accessor to the bootstrap size used to sample the posterior distribution.

Returns:
sizeint

Bootstrap size used to sample the posterior distribution. A value of 0 means that no bootstrap has been done but a linear approximation has been used to get the posterior distribution, using the GaussianLinearCalibration algorithm at the maximum a posteriori estimate.

getClassName()

Accessor to the object’s name.

Returns:
class_namestr

The object class name (object.__class__.__name__).

getErrorCovariance()

Accessor to the observation error covariance.

Returns:
errorCovarianceMatrix

Observation error covariance.

getGlobalErrorCovariance()

Accessor to the flag for a global observation error covariance.

Returns:
flagbool

Flag telling if the given observation error covariance is global or not.

getId()

Accessor to the object’s id.

Returns:
idint

Internal unique identifier.

getInputObservations()

Accessor to the input data to be fitted.

Returns:
dataSample

The input data to be fitted.

getModel()

Accessor to the model to be fitted.

Returns:
dataFunction

The model to be fitted.

getName()

Accessor to the object’s name.

Returns:
namestr

The name of the object.

getOptimizationAlgorithm()

Accessor to the optimization algorithm used for the computation.

Returns:
algoOptimizationAlgorithm

Optimization algorithm used for the computation.

getOutputObservations()

Accessor to the output data to be fitted.

Returns:
dataSample

The output data to be fitted.

getParameterCovariance()

Accessor to the parameter prior covariance.

Returns:
priorCovarianceMatrix

Parameter prior covariance.

getParameterMean()

Accessor to the parameter parameterMean.

Returns:
parameterMeanPoint

Parameter parameterMean.

getParameterPrior()

Accessor to the parameter prior distribution.

Returns:
priorDistribution

The parameter prior distribution.

getResult()

Get the result structure.

Returns:
resCalibration: CalibrationResult

The structure containing all the results of the calibration problem.

Notes

The structure contains all the results of the calibration problem.

getShadowedId()

Accessor to the object’s shadowed id.

Returns:
idint

Internal unique identifier.

getVisibility()

Accessor to the object’s visibility state.

Returns:
visiblebool

Visibility flag.

hasName()

Test if the object is named.

Returns:
hasNamebool

True if the name is not empty.

hasVisibleName()

Test if the object has a distinguishable name.

Returns:
hasVisibleNamebool

True if the name is not empty and not the default one.

run(*args)

Launch the algorithm.

Notes

It launches the algorithm and creates a CalibrationResult, structure containing all the results.

setBootstrapSize(bootstrapSize)

Accessor to the bootstrap size used to sample the posterior distribution.

Parameters:
sizeint

Bootstrap size used to sample the posterior distribution. A value of 0 means that no bootstrap has to be done but a linear approximation has been used to get the posterior distribution, using the GaussianLinearCalibration algorithm at the maximum a posteriori estimate.

setName(name)

Accessor to the object’s name.

Parameters:
namestr

The name of the object.

setOptimizationAlgorithm(algorithm)

Accessor to the optimization algorithm used for the computation.

Parameters:
algoOptimizationAlgorithm

Optimization algorithm to use for the computation.

setResult(result)

Accessor to optimization result.

Parameters:
resultCalibrationResult

Result class.

setShadowedId(id)

Accessor to the object’s shadowed id.

Parameters:
idint

Internal unique identifier.

setVisibility(visible)

Accessor to the object’s visibility state.

Parameters:
visiblebool

Visibility flag.

Examples using the class

Calibration of the deflection of a tube

Calibration of the deflection of a tube

Calibration of the flooding model

Calibration of the flooding model

Calibration of the Chaboche mechanical model

Calibration of the Chaboche mechanical model