# 14.6. Checking algorithm “*LinearityTest*”¶

## 14.6.1. Description¶

This algorithm allows to check the linear quality of the operator, by calculating a residue with known theoretical properties. Different residue formula are available.

In any cases, one take and . is the calculation code.

### 14.6.1.1. “CenteredDL” residue¶

One observe the following residue, coming from the centered difference of the values at nominal point and at perturbed points, normalized by the value at the nominal point:

If it stays constantly really small with respect to 1, the linearity hypothesis of is verified.

If the residue is varying, or if it is of order 1 or more, and it is small only at a certain order of increment, the linearity hypothesis of is not verified.

If the residue is decreasing and the decrease change in with respect to , it signifies that the gradient is correctly calculated until the stopping level of the quadratic decrease.

### 14.6.1.2. “Taylor” residue¶

One observe the residue coming from the Taylor development of the function, normalized by the value at the nominal point:

If it stay constantly really small with respect to 1, the linearity hypothesis of is verified.

If the residue is varying, or if it is of order 1 or more, and it is small only at a certain order of increment, the linearity hypothesis of is not verified.

If the residue is decreasing and the decrease change in with respect to , it signifies that the gradient is correctly calculated until the stopping level of the quadratic decrease.

### 14.6.1.3. “NominalTaylor” residue¶

One observe the residue build from two approximations of order 1 of , normalized by the value at the nominal point:

If the residue stays constant equal to 1 at less than 2 or 3 percents (that that stays equal to 2 or 3 percents), the linearity hypothesis of is verified.

If it is equal to 1 only on part of the variation domain of increment , it is on this sub-domain that the linearity hypothesis of is verified.

### 14.6.1.4. “NominalTaylorRMS” residue¶

One observe the residue build from two approximations of order 1 of , normalized by the value at the nominal point, on which one estimate the quadratic root mean square (RMS) with the value at the nominal point:

If it stay constantly equal to 0 at less than 1 or 2 percents, the linearity hypothesis of is verified.

If it is equal to 0 only on part of the variation domain of increment , it is on this sub-domain that the linearity hypothesis of is verified.

## 14.6.2. Optional and required commands¶

The general required commands, available in the editing user graphical or textual interface, are the following:

- CheckingPoint
*Vector*. The variable indicates the vector used as the state around which to perform the required check, noted and similar to the background . It is defined as a “*Vector*” or “*VectorSerie*” type object. Its availability in output is conditioned by the boolean “*Stored*” associated with input.

- ObservationOperator
*Operator*. The variable indicates the observation operator, usually noted as , which transforms the input parameters to results to be compared to observations . Its value is defined as a “*Function*” type object or a “*Matrix*” type one. In the case of “*Function*” type, different functional forms can be used, as described in the section Requirements for functions describing an operator. If there is some control included in the observation, the operator has to be applied to a pair .

The general optional commands, available in the editing user graphical or
textual interface, are indicated in List of commands and keywords for an ADAO checking case.
Moreover, the parameters of the command “*AlgorithmParameters*” allow to choose
the specific options, described hereafter, of the algorithm. See
Description of options of an algorithm by “AlgorithmParameters” for the good use of this
command.

The options are the following:

- AmplitudeOfInitialDirection
*Real value*. This key indicates the scaling of the initial perturbation build as a vector used for the directional derivative around the nominal checking point. The default is 1, that means no scaling.Example:

`{"AmplitudeOfInitialDirection":0.5}`

- AmplitudeOfTangentPerturbation
*Real value*. This key indicates the relative numerical magnitude of the perturbation used to estimate the tangent value of the operator at the evaluation point, i.e. its directional derivative. The conservative default is 1.e-2 i.e. 1%, and it is strongly recommended to adapt it to the needs of real problems, by decreasing its value by several orders of magnitude.Example :

`{"AmplitudeOfTangentPerturbation":1.e-2}`

- EpsilonMinimumExponent
*Integer value*. This key indicates the minimal exponent value of the power of 10 coefficient to be used to decrease the increment multiplier. The default is -8, and it has to be negative between 0 and -20. For example, its default value leads to calculate the residue of the scalar product formula with a fixed increment multiplied from 1.e0 to 1.e-8.Example:

`{"EpsilonMinimumExponent":-12}`

- InitialDirection
*Vector*. This key indicates the vector direction used for the directional derivative around the nominal checking point. It has to be a vector of the same vector size than the checking point. If not specified, this direction defaults to a random perturbation around zero of the same vector size than the checking point.Example:

`{"InitialDirection":[0.1,0.1,100.,3}`

for a state space of dimension 4

- NumberOfPrintedDigits
*Integer value*. This key indicates the number of digits of precision for floating point printed output. The default is 5, with a minimum of 0.Example:

`{"NumberOfPrintedDigits":5}`

- ResiduFormula
*Predefined name*. This key indicates the residue formula that has to be used for the test. The default choice is “CenteredDL”, and the possible ones are “CenteredDL” (residue of the difference between the function at nominal point and the values with positive and negative increments, which has to stay very small), “Taylor” (residue of the Taylor development of the operator normalized by the nominal value, which has to stay very small), “NominalTaylor” (residue of the order 1 approximations of the operator, normalized to the nominal point, which has to stay close to 1), and “NominalTaylorRMS” (residue of the order 1 approximations of the operator, normalized by RMS to the nominal point, which has to stay close to 0).Example :

`{"ResiduFormula":"CenteredDL"}`

- SetSeed
*Integer value*. This key allow to give an integer in order to fix the seed of the random generator used in the algorithm. By default, the seed is left uninitialized, and so use the default initialization from the computer, which then change at each study. To ensure the reproducibility of results involving random samples, it is strongly advised to initialize the seed. A simple convenient value is for example 123456789. It is recommended to put an integer with more than 6 or 7 digits to properly initialize the random generator.Example:

`{"SetSeed":123456789}`

- StoreSupplementaryCalculations
*List of names*. This list indicates the names of the supplementary variables, that can be available during or at the end of the algorithm, if they are initially required by the user. Their availability involves, potentially, costly calculations or memory consumptions. The default is then a void list, none of these variables being calculated and stored by default (excepted the unconditional variables). The possible names are in the following list (the detailed description of each named variable is given in the following part of this specific algorithmic documentation, in the sub-section “*Information and variables available at the end of the algorithm*”): [ “CurrentState”, “Residu”, “SimulatedObservationAtCurrentState”, ].Example :

`{"StoreSupplementaryCalculations":["CurrentState", "Residu"]}`

## 14.6.3. Information and variables available at the end of the algorithm¶

At the output, after executing the algorithm, there are information and
variables originating from the calculation. The description of
Variables and information available at the output show the way to obtain them by the method
named `get`

, of the variable “*ADD*” of the post-processing in graphical
interface, or of the case in textual interface. The input variables, available
to the user at the output in order to facilitate the writing of post-processing
procedures, are described in the Inventory of potentially available information at the output.

**Permanent outputs (non conditional)**

The unconditional outputs of the algorithm are the following:

- Residu
*List of values*. Each element is the value of the particular residue checked during the running of the algorithm, in the order of the tests.Example:

`r = ADD.get("Residu")[:]`

**Set of on-demand outputs (conditional or not)**

The whole set of algorithm outputs (conditional or not), sorted by alphabetical order, is the following:

- CurrentState
*List of vectors*. Each element is a usual state vector used during the iterative algorithm procedure.Example:

`xs = ADD.get("CurrentState")[:]`

- Residu
*List of values*. Each element is the value of the particular residue checked during the running of the algorithm, in the order of the tests.Example:

`r = ADD.get("Residu")[:]`

- SimulatedObservationAtCurrentState
*List of vectors*. Each element is an observed vector simulated by the observation operator from the current state, that is, in the observation space.Example:

`hxs = ADD.get("SimulatedObservationAtCurrentState")[-1]`