# HSICEstimatorConditionalSensitivity¶

class HSICEstimatorConditionalSensitivity(*args)

Implement a HSIC estimator for conditional analysis.

Parameters:
covarianceModelCollectionlist of `CovarianceModel`

List of all covariance kernels. The first kernels are linked to the input and the last one is for the output.

X2-d sequence of float

The input sample used for the HSIC analysis of dimension .

Y2-d sequence of float

The output sample used for the HSIC analysis of dimension 1.

weightFunction`Function`

A weight function used for the inputs.

Notes

Conditional sensitivity analysis relies on the `HSICVStat` estimator. Also it does not provides an asymptotic estimate of the p-values thus the generic methods getPValuesAsymptotic and drawPValuesAsymptotic throws an exception in that case.

Examples

```>>> import openturns as ot
>>> from math import pi
```

Generate input and output samples.

```>>> # 3d input distribution with an independent copula
>>> distX = ot.ComposedDistribution([ot.Uniform(-pi, pi)] * 3)
>>> X = distX.getSample(100) # get a sample
>>>
>>> # Apply the Ishigami model.
>>> inputs = ['X1', 'X2', 'X3']
>>> formula = ['sin(X1) + 5.0 * (sin(X2))^2 + 0.1 * X3^4 * sin(X1)']
>>> modelIshigami = ot.SymbolicFunction(inputs, formula)
>>> Y = modelIshigami(X) # Y = modelIshigami(X)
```

Define covariance kernels for the model inputs. Put them in a list.

```>>> covarianceModelCollection = []
>>> for i in range(3):
...     Xi = X.getMarginal(i)
...     Cov = ot.SquaredExponential(1)
...     Cov.setScale(Xi.computeStandardDeviation())
...     covarianceModelCollection.append(Cov)
```

Append the list with the covariance kernel for the model output.

```>>> covarianceModelCollection.append(ot.SquaredExponential(Y.computeStandardDeviation()))
```

To perform sensititivity analysis under the condition that the output belongs or is near a domain, define a weight function based on the distance to this domain.

```>>> dist = ot.DistanceToDomainFunction(ot.Interval(5, float('inf')))
>>> func = ot.SymbolicFunction('x', 'exp(-0.5 * x)')
>>> weight = ot.ComposedFunction(func, dist)
```

Build and use the HSIC estimator for conditional sensitivity analysis.

```>>> hsic = ot.HSICEstimatorConditionalSensitivity(covarianceModelCollection, X, Y, weight)
>>> print(hsic.getR2HSICIndices())
[0.280788,0.00600014,0.0577616]
```

Methods

 Draw the HSIC indices. Draw the p-values obtained with an asymptotic formula. Draw the p-values obtained by permutation. Draw the R2-HSIC indices. Accessor to the object's name. Get the list of all covariance models used. Get the dimension of the input sample. Get the estimator used for computations. Get the HSIC indices. Accessor to the object's id. Get the input sample. Accessor to the object's name. Get the output sample. Get the p-values obtained with an asymptotic formula. Get the p-value estimated through permutations. Get the number of permutations. Get the R2-HSIC indices. Accessor to the object's shadowed id. Get the size of the input sample. Accessor to the object's visibility state. Get the weight function used. Test if the object is named. Test if the object has a distinguishable name. Compute all values at once. Set the covariance models. `setInputSample`(inputSample) Set the input sample. `setName`(name) Accessor to the object's name. `setOutputSample`(outputSample) Set the output sample. Set the number of permutations to be used for p-value estimate. Accessor to the object's shadowed id. `setVisibility`(visible) Accessor to the object's visibility state. `setWeightFunction`(weightFunction) Set the weight function.
 computeWeights
__init__(*args)
drawHSICIndices()

Draw the HSIC indices.

Returns:
graph`Graph`

The graph of all HSIC indices according to components.

drawPValuesAsymptotic()

Draw the p-values obtained with an asymptotic formula.

Returns:
graph`Graph`

The graph of all p-values estimated with an asymptotic formula.

drawPValuesPermutation()

Draw the p-values obtained by permutation.

Returns:
graph`Graph`

The graph of all p-values by permutation according to components.

drawR2HSICIndices()

Draw the R2-HSIC indices.

Returns:
graph`Graph`

The graph of all R2-HSIC indices according to components.

getClassName()

Accessor to the object’s name.

Returns:
class_namestr

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

getCovarianceModelCollection()

Get the list of all covariance models used.

Returns:
collCovarianceModelCollection

The list of all covariance models used. The last one is the output covariance model.

getDimension()

Get the dimension of the input sample.

Returns:
dimint

The dimension of the input sample.

getEstimator()

Get the estimator used for computations.

Returns:
estimator`HSICStat`

The estimator used for internal computations.

getHSICIndices()

Get the HSIC indices.

Returns:
hsicIndices`Point`

The HSIC indices of all components.

getId()

Accessor to the object’s id.

Returns:
idint

Internal unique identifier.

getInputSample()

Get the input sample.

Returns:
inSample`Sample`

The input sample used for analysis.

getName()

Accessor to the object’s name.

Returns:
namestr

The name of the object.

getOutputSample()

Get the output sample.

Returns:
outSample`Sample`

The output sample used for analysis.

getPValuesAsymptotic()

Get the p-values obtained with an asymptotic formula.

Returns:
pvalsequence of float

The p-values for all components.

getPValuesPermutation()

Get the p-value estimated through permutations.

Returns:
pval`Point`

The p-values of all components estimated with permutations of the data.

getPermutationSize()

Get the number of permutations.

Returns:
permutationSizeint

The number of permutations.

getR2HSICIndices()

Get the R2-HSIC indices.

Returns:
r2hsicIndices`Point`

The R2-HSIC indices of all components.

Accessor to the object’s shadowed id.

Returns:
idint

Internal unique identifier.

getSize()

Get the size of the input sample.

Returns:
sizeint

The size of the input sample.

getVisibility()

Accessor to the object’s visibility state.

Returns:
visiblebool

Visibility flag.

getWeightFunction()

Get the weight function used.

Returns:
weightFunction`Function`

The weight function used for the conditional estimator.

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()

Compute all values at once.

setCovarianceModelCollection(coll)

Set the covariance models.

Parameters:
collCovarianceModelCollection

The list of all covariance models.

setInputSample(inputSample)

Set the input sample.

Parameters:
inputSample2-d sequence of float

The input sample to be used.

setName(name)

Accessor to the object’s name.

Parameters:
namestr

The name of the object.

setOutputSample(outputSample)

Set the output sample.

Parameters:
outputSample2-d sequence of float

The output sample to be used.

setPermutationSize(B)

Set the number of permutations to be used for p-value estimate.

Parameters:
Bint

The number of permutation used for p-value estimates.

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.

setWeightFunction(weightFunction)

Set the weight function.

Parameters:
weightFunction`Function`

The weight function used for the conditional estimator.

## Examples using the class¶

The HSIC sensitivity indices: the Ishigami model

The HSIC sensitivity indices: the Ishigami model