NonLinearLeastSquaresCalibration

class NonLinearLeastSquaresCalibration(*args)

Non-linear least-squares calibration algorithm.

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.

startingPointsequence of float

The reference value of the parameter, used as the starting point of the optimization.

Methods

BuildResidualFunction(model, ...)

Build a residual function given a parametric model, input and output observations.

getBootstrapSize()

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

getClassName()

Accessor to the object's name.

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.

getParameterPrior()

Accessor to the parameter prior distribution.

getResult()

Get the result structure.

getStartingPoint()

Accessor to the parameter startingPoint.

hasName()

Test if the object is named.

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.

Notes

NonLinearLeastSquaresCalibration is the minimum variance estimator of the parameter of a given model with no assumption on the dependence of the model with respect to the parameter.

The prior distribution of the parameter is a noninformative prior emulated using a flat Normal centered on the startingPoint and with a variance equal to SpecFunc.Infinity.

The posterior distribution of the parameter is Normal and reflects the variability of the optimum parameter depending on the observation sample. By default, the posterior distribution is evaluated based on a linear approximation of the model at the optimum. This corresponds to using the LinearLeastSquaresCalibration at the optimum, and is named Laplace approximation in the Bayesian context. However, if the key NonLinearLeastSquaresCalibration-BootstrapSize in the ResourceMap 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.

The resulting distribution of the output error is a Normal and is computed from the residuals.

If least squares optimization algorithms are enabled, then the algorithm used is the first found by Build of OptimizationAlgorithm. Otherwise, the algorithm TNC is used.

Please read Code calibration for more details.

Examples

Calibrate a nonlinear model using non-linear least-squares:

>>> 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)
>>> startingPoint = [1.0]*3
>>> algo = ot.NonLinearLeastSquaresCalibration(modelX, x, y, startingPoint)
>>> algo.run()
>>> print(algo.getResult().getParameterMAP())
[2.773...,1.203...,0.499...]
__init__(*args)
static BuildResidualFunction(model, inputObservations, outputObservations)

Build a residual function given a parametric model, input and output observations.

Parameters:
modelFunction

Parametric model.

inputObservations2-d sequence of float

Input observations associated to the output observations.

outputObservationsFunction

Output observations.

Returns:
residualFunction
Residual function.

Notes

Given a parametric model F_{\theta}:\Rset^n\rightarrow\Rset^p with parameter \theta\in\Rset^m, a sample of input points (x_i)_{i=1,\dots,N} and the associated output (y_i)_{i=1,\dots,N}, the residual function f is defined by:

\forall \theta\in\Rset^m, f(\theta)=\left(\begin{array}{c}
F_{\theta}(x_1)-y_1 \\
\vdots \\
F_{\theta}(x_N)-y_N
\end{array}
\right)

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__).

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.

getParameterPrior()

Accessor to the parameter prior distribution.

Returns:
priorDistribution

The parameter prior distribution.

getResult()

Get the result structure.

Returns:
resCalibrationCalibrationResult

The structure containing all the results of the calibration problem.

Notes

The structure contains all the results of the calibration problem.

getStartingPoint()

Accessor to the parameter startingPoint.

Returns:
startingPointPoint

Parameter startingPoint.

hasName()

Test if the object is named.

Returns:
hasNamebool

True if the name is not empty.

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.

Examples using the class

Create a parametric function

Create a parametric function

Calibrate a parametric model: a quick-start guide to calibration

Calibrate a parametric model: a quick-start guide to calibration

Calibration of the flooding model

Calibration of the flooding model

Calibration of the Chaboche mechanical model

Calibration of the Chaboche mechanical model