ConditionalDistribution

class ConditionalDistribution(distribution, conditionalIndices, conditionalRefencePoint, maximumSubIntervals=10000, maximumError=0.001, useIntegration=True, sampleSizeForCDFBySampling=10000, verbose=False)

A class to create a conditional distribution.

Methods

ComputeRange(distribution, ...)

Compute the range of the conditional distribution.

computeCDF(Y)

Returns the CDF.

computeExtendedInput(Y)

Compute the extended input from the conditioned input.

computePDF(Y)

Returns the PDF.

getDescription()

Returns the description.

getDimension()

Dimension accessor.

getRange()

Returns the range.

__init__(distribution, conditionalIndices, conditionalRefencePoint, maximumSubIntervals=10000, maximumError=0.001, useIntegration=True, sampleSizeForCDFBySampling=10000, verbose=False)

Create a conditional distribution.

This is the random variable:

Y = (X | X[i]=conditionalRefencePoint[i])

for i in conditionalIndices.

The dimension of Y is the dimension of X minus the number of conditioned indices:

dimension(Y) = dimension(X) - len(conditionalIndices)

Computing the CDF of the distribution requires a numerical integration. This is done with IteratedQuadrature based on the univariate GaussKronrod integration method.

Parameters:
distributionot.Distribution

The distribution to be conditioned.

conditionalIndiceslist

The indices of the marginals which are conditioned

conditionalRefencePointlist

The values of the marginal which are conditioned

maximumSubIntervalsint

The maximal number of subdivisions of the univariate interval.

maximumErrorfloat

The maximal error between Gauss and Kronrod approximations.

useIntegrationbool

Set to True to use integration, False to use sampling. Default is True.

sampleSizeForCDFBySamplingint

The sample size used for sampling. The default is 10000.

verbosebool

Set to True to print intermediate messages. Default is False.

Examples

# The random variable is (X0, X1, X2) >>> import openturns as ot >>> import otbenchmark as otb >>> distribution = ot.Normal(3) # We condition X = (X0, X1, X2) given X1=2.0, X2=3.0 >>> conditionalIndices = [1, 2] >>> conditionalRefencePoint = [2.0, 3.0] >>> conditionalDistribution = ot.Distribution(otb.ConditionalDistribution( … distribution, conditionalIndices, conditionalRefencePoint)) # PDF >>> computed = conditionalDistribution.computePDF([1.0])

static ComputeRange(distribution, conditionalIndices, conditionalRefencePoint)

Compute the range of the conditional distribution.

Parameters:
distributionot.Distribution

The distribution to be conditioned.

conditionalIndiceslist

The indices of the marginal which are conditioned

conditionalRefencePointlist

The values of the marginal which are conditioned

Returns:
conditionalRangeot.Interval

The range of the conditional distribution.

computeCDF(Y)

Returns the CDF.

Parameters:
Yot.Point(dimension_Y)

The input point.

Returns:
pfloat

The CDF of the conditional distribution.

computeExtendedInput(Y)

Compute the extended input from the conditioned input.

The conditioned input is Y. The function returns the vector

X = (X[0], X[1], …, X[dimension - 1])

so that

X[i] = X[i] if i is conditionned conditionalRefencePoint[i] otherwise,

for i = 0, 1, …, dimension - 1.

The following algorithm implements this:

X = []
referenceIndex = 0
conditionalIndex = 0
for i in range(self.extendedDimension):
    if i in self.conditionalIndices:
        X.append(self.conditionalRefencePoint[referenceIndex])
        referenceIndex += 1
    else:
        X.append(X[conditionalIndex])
        conditionalIndex += 1

The actual code is, however, vectorized using numpy.

Parameters:
Yot.Point

The conditioned input point.

extendedDimensionint

The extended dimension.

conditionalIndiceslist

The indices of the marginal which are conditioned

conditionalRefencePointlist

The values of the marginal which are conditioned

Returns:
Xot.Point

The extended input point, as an input of the full distribution.

computePDF(Y)

Returns the PDF.

Returns:
yfloat

The PDF of the conditional distribution.

getDescription()

Returns the description.

Returns:
descriptionot.Description

The description of the conditional distribution.

getDimension()

Dimension accessor.

getRange()

Returns the range.

Returns:
conditionalRangeot.Interval

The range of the conditional distribution.