RandomMixture distribution¶
(Source code
, png
)
- class RandomMixture(*args)¶
RandomMixture distribution.
Refer to Affine combination of independent univariate random variables.
- Available constructors:
RandomMixture(coll, cst)
RandomMixture(coll, weights, cst)
RandomMixture(coll, weightsMatrix)
RandomMixture(coll, weightsMatrix, constant)
- Parameters:
- colllist of
Distribution
The collection of distributions that model the random vector.
- cstfloat
Constant coefficient of the affine expression in dimension 1. Default value is zero.
- weightssequence of float
Weights of the affine combination in dimension 1. Default value is (1, …,1).
- constantsequence of float
Constant vector of the affine expression. Its size should be equal to the dimension of the distribution. Default value is (0,…,0).
- weightsMatrix2-d sequence of float
Weights of the affine combination.
- colllist of
Notes
- Create an affine combination of input random variables of form:
- where: of size with
is a -random vector with independent components, i.e. a collection of univariate distributions,
is a deterministic matrix, i.e. the linear operator of the affine transformation,
a constant and deterministic vector, i.e the constant part of the affine transformation.
As the univariate random variables are independent, the characteristic function of , denoted , is easily defined from the characteristic function of denoted as follows :
It is possible to evaluate its density probability function once the characteristic function evaluated, using the Poisson summation formula:
For small enough, the nested sums of the left term are reduced to the central term . Thus, the density is approximated by:
The nested sums of the right term are computed by blocks of form , and are truncated when the contribution of a block becomes lower than a threshold, which can be changed by setPDFPrecision method. Two other methods also may change the number of iterations; setBlockMin sets the block number from which truncation is possible, which means that computations are always performed for blocks lower than this parameter, even if their contributions are very small. On the other hand, setBlockMax sets the maximum number of blocks, which can be useful to make sure that computations run in a limited time.
Note that the total number of evaluations of the characteristic function to compute up to block is equivalent to , so it is important to ensure that this number has some reasonable value.
Note finally that the characteristic function evaluations are independent from : these values are stored in a cache.
Its first moments are:
Examples
Create a distribution:
>>> import openturns as ot >>> coll = [ot.Triangular(0.0, 1.0, 5.0), ot.Uniform(-2.0, 2.0)] >>> weights = [3.0, 2.0] >>> cst = 3.0 >>> distribution = ot.RandomMixture(coll, weights, cst)
Draw a sample:
>>> sample = distribution.getSample(5)
Methods
abs
()Transform distribution by absolute value function.
acos
()Transform distribution by arccosine function.
acosh
()Transform distribution by acosh function.
asin
()Transform distribution by arcsine function.
asinh
()Transform distribution by asinh function.
atan
()Transform distribution by arctangent function.
atanh
()Transform distribution by atanh function.
cbrt
()Transform distribution by cubic root function.
Compute a bilateral confidence interval.
computeBilateralConfidenceIntervalWithMarginalProbability
(prob)Compute a bilateral confidence interval.
computeCDF
(*args)Compute the cumulative distribution function.
computeCDFGradient
(*args)Compute the gradient of the cumulative distribution function.
Compute the characteristic function.
computeComplementaryCDF
(*args)Compute the complementary cumulative distribution function.
computeConditionalCDF
(*args)Compute the conditional cumulative distribution function.
computeConditionalDDF
(x, y)Compute the conditional derivative density function of the last component.
computeConditionalPDF
(*args)Compute the conditional probability density function.
computeConditionalQuantile
(*args)Compute the conditional quantile function of the last component.
computeDDF
(*args)Compute the derivative density function.
computeDensityGenerator
(betaSquare)Compute the probability density function of the characteristic generator.
computeDensityGeneratorDerivative
(betaSquare)Compute the first-order derivative of the probability density function.
Compute the second-order derivative of the probability density function.
Compute the entropy of the distribution.
computeGeneratingFunction
(*args)Compute the probability-generating function.
Compute the inverse survival function.
Compute the logarithm of the characteristic function.
computeLogGeneratingFunction
(*args)Compute the logarithm of the probability-generating function.
computeLogPDF
(*args)Compute the logarithm of the probability density function.
computeLogPDFGradient
(*args)Compute the gradient of the log probability density function.
Compute the lower extremal dependence coefficients.
Compute the lower tail dependence coefficients.
Compute the confidence interval with minimum volume.
Compute the confidence interval with minimum volume.
Compute the confidence domain with minimum volume.
Compute the confidence domain with minimum volume.
computePDF
(*args)Compute the probability density function.
computePDFGradient
(*args)Compute the gradient of the probability density function.
computeProbability
(interval)Compute the interval probability.
computeQuantile
(*args)Compute the quantile function.
computeRadialDistributionCDF
(radius[, tail])Compute the cumulative distribution function of the squared radius.
computeScalarQuantile
(prob[, tail])Compute the quantile function for univariate distributions.
Compute the sequential conditional cumulative distribution functions.
Compute the sequential conditional derivative density function.
Compute the sequential conditional probability density function.
Compute the conditional quantile function of the last component.
computeSurvivalFunction
(*args)Compute the survival function.
computeUnilateralConfidenceInterval
(prob[, tail])Compute a unilateral confidence interval.
computeUnilateralConfidenceIntervalWithMarginalProbability
(...)Compute a unilateral confidence interval.
Compute the upper extremal dependence coefficients.
Compute the upper tail dependence coefficients.
cos
()Transform distribution by cosine function.
cosh
()Transform distribution by cosh function.
drawCDF
(*args)Draw the cumulative distribution function.
drawLogPDF
(*args)Draw the graph or of iso-lines of log-probability density function.
Draw the lower extremal dependence function.
Draw the lower tail dependence function.
drawMarginal1DCDF
(marginalIndex, xMin, xMax, ...)Draw the cumulative distribution function of a margin.
drawMarginal1DLogPDF
(marginalIndex, xMin, ...)Draw the log-probability density function of a margin.
drawMarginal1DPDF
(marginalIndex, xMin, xMax, ...)Draw the probability density function of a margin.
drawMarginal1DSurvivalFunction
(...[, logScale])Draw the cumulative distribution function of a margin.
drawMarginal2DCDF
(firstMarginal, ...[, ...])Draw the cumulative distribution function of a couple of margins.
drawMarginal2DLogPDF
(firstMarginal, ...[, ...])Draw the log-probability density function of a couple of margins.
drawMarginal2DPDF
(firstMarginal, ...[, ...])Draw the probability density function of a couple of margins.
drawMarginal2DSurvivalFunction
(...[, ...])Draw the cumulative distribution function of a couple of margins.
drawPDF
(*args)Draw the graph or of iso-lines of probability density function.
drawQuantile
(*args)Draw the quantile function.
drawSurvivalFunction
(*args)Draw the cumulative distribution function.
Draw the upper extremal dependence function.
Draw the upper tail dependence function.
exp
()Transform distribution by exponential function.
getAlpha
()Return the priori range of PDF and CDF argument.
getBeta
()Return the distance of the a priori range at which the PDF is negligible.
Return the blockMax parameter.
Return the blockMin parameter.
Accessor to the CDF computation precision.
Accessor to the componentwise central moments.
Accessor to the Cholesky factor of the covariance matrix.
Accessor to the object's name.
Return the vector of the affine combination.
Accessor to the copula of the distribution.
(ditch me?)
Accessor to the covariance matrix.
Accessor to the componentwise description.
Accessor to the dimension of the distribution.
Dispersion indicator accessor.
Return the list of distributions used.
getId
()Accessor to the object's id.
Accessor to the number of Gauss integration points.
Accessor to the inverse Cholesky factor of the covariance matrix.
Accessor to the inverse iso-probabilistic transformation.
Accessor to the iso-probabilistic transformation.
Accessor to the Kendall coefficients matrix.
Accessor to the componentwise kurtosis.
getMarginal
(*args)Accessor to marginal distributions.
Return the maximum size of cache for characteristic function evaluations.
getMean
()Accessor to the mean.
getMoment
(n)Accessor to the componentwise moments.
getName
()Accessor to the object's name.
Accessor to the PDF computation precision.
Accessor to the parameter of the distribution.
Accessor to the parameter description of the distribution.
Accessor to the number of parameters in the distribution.
Accessor to the parameter of the distribution.
Accessor to the Pearson correlation matrix.
Position indicator accessor.
Accessor to the discrete probability levels.
getRange
()Accessor to the range of the distribution.
Accessor to a pseudo-random realization from the distribution.
Return the reference bandwidth.
Accessor to roughness of the distribution.
getSample
(size)Accessor to a pseudo-random sample from the distribution.
getSampleByInversion
(size)Accessor to a pseudo-random sample from the distribution.
getSampleByQMC
(size)Accessor to a low discrepancy sample from the distribution.
Accessor to the object's shadowed id.
Accessor to the shape matrix of the underlying copula if it is elliptical.
getShiftedMoment
(n, shift)Accessor to the componentwise shifted moments.
Accessor to the singularities of the PDF function.
Accessor to the componentwise skewness.
Accessor to the Spearman correlation matrix.
Accessor to the componentwise standard deviation.
Accessor to the standard distribution.
Accessor to the standard representative distribution in the parametric family.
getSupport
(*args)Accessor to the support of the distribution.
Accessor to the object's visibility state.
Return the weights of the combination as a Matrix.
Test whether the copula of the distribution is elliptical or not.
Test whether the copula of the distribution is the independent one.
hasName
()Test if the object is named.
Test if the object has a distinguishable name.
inverse
()Transform distribution by inverse function.
Test whether the distribution is continuous or not.
isCopula
()Test whether the distribution is a copula or not.
Test whether the distribution is discrete or not.
Test whether the distribution is elliptical or not.
Test whether the distribution is integer-valued or not.
ln
()Transform distribution by natural logarithm function.
log
()Transform distribution by natural logarithm function.
project
(*args)Project a RandomMixture distribution over a collection of DistributionFactory.
setAlpha
(alpha)Set the a priori range of PDF and CDF arguments in terms of standard deviation.
setBeta
(beta)Set the distance of the a priori range at which the PDF is negligible.
setBlockMax
(blockMax)Set the blockMax parameter.
setBlockMin
(blockMin)Set the blockMin parameter.
setCDFPrecision
(cdfPrecision)Set the requested precision for CDF computation.
setConstant
(constant)Set the constant term of the affine combination.
setDescription
(description)Accessor to the componentwise description.
setIntegrationNodesNumber
(integrationNodesNumber)Accessor to the number of Gauss integration points.
setMaxSize
(maxSize)Set the maximum size of cache for characteristic function evaluations.
setName
(name)Accessor to the object's name.
setPDFPrecision
(pdfPrecision)Set the requested precision for PDF computation.
setParameter
(parameter)Accessor to the parameter of the distribution.
setParametersCollection
(*args)Accessor to the parameter of the distribution.
setReferenceBandwidth
(bandwidth)Set the reference bandwidth.
setShadowedId
(id)Accessor to the object's shadowed id.
setVisibility
(visible)Accessor to the object's visibility state.
sin
()Transform distribution by sine function.
sinh
()Transform distribution by sinh function.
sqr
()Transform distribution by square function.
sqrt
()Transform distribution by square root function.
tan
()Transform distribution by tangent function.
tanh
()Transform distribution by tanh function.
getFFTAlgorithm
setFFTAlgorithm
- __init__(*args)¶
- abs()¶
Transform distribution by absolute value function.
- Returns:
- dist
Distribution
The transformed distribution.
- dist
- acos()¶
Transform distribution by arccosine function.
- Returns:
- dist
Distribution
The transformed distribution.
- dist
- acosh()¶
Transform distribution by acosh function.
- Returns:
- dist
Distribution
The transformed distribution.
- dist
- asin()¶
Transform distribution by arcsine function.
- Returns:
- dist
Distribution
The transformed distribution.
- dist
- asinh()¶
Transform distribution by asinh function.
- Returns:
- dist
Distribution
The transformed distribution.
- dist
- atan()¶
Transform distribution by arctangent function.
- Returns:
- dist
Distribution
The transformed distribution.
- dist
- atanh()¶
Transform distribution by atanh function.
- Returns:
- dist
Distribution
The transformed distribution.
- dist
- cbrt()¶
Transform distribution by cubic root function.
- Returns:
- dist
Distribution
The transformed distribution.
- dist
- computeBilateralConfidenceInterval(prob)¶
Compute a bilateral confidence interval.
- Parameters:
- alphafloat,
The confidence level.
- Returns:
- confInterval
Interval
The confidence interval of level .
- confInterval
Notes
We consider an absolutely continuous measure with density function .
The bilateral confidence interval is the cartesian product where and for all and which verifies .
Examples
Create a sample from a Normal distribution:
>>> import openturns as ot >>> sample = ot.Normal().getSample(10) >>> ot.ResourceMap.SetAsUnsignedInteger('DistributionFactory-DefaultBootstrapSize', 100)
Fit a Normal distribution and extract the asymptotic parameters distribution:
>>> fittedRes = ot.NormalFactory().buildEstimator(sample) >>> paramDist = fittedRes.getParameterDistribution()
Determine the bilateral confidence interval at level 0.9:
>>> confInt = paramDist.computeBilateralConfidenceInterval(0.9)
- computeBilateralConfidenceIntervalWithMarginalProbability(prob)¶
Compute a bilateral confidence interval.
Refer to
computeBilateralConfidenceInterval()
- Parameters:
- alphafloat,
The confidence level.
- Returns:
- confInterval
Interval
The confidence interval of level .
- marginalProbfloat
The value which is the common marginal probability of each marginal interval.
- confInterval
Examples
Create a sample from a Normal distribution:
>>> import openturns as ot >>> sample = ot.Normal().getSample(10) >>> ot.ResourceMap.SetAsUnsignedInteger('DistributionFactory-DefaultBootstrapSize', 100)
Fit a Normal distribution and extract the asymptotic parameters distribution:
>>> fittedRes = ot.NormalFactory().buildEstimator(sample) >>> paramDist = fittedRes.getParameterDistribution()
Determine the bilateral confidence interval at level 0.9 with marginal probability:
>>> confInt, marginalProb = paramDist.computeBilateralConfidenceIntervalWithMarginalProbability(0.9)
- computeCDF(*args)¶
Compute the cumulative distribution function.
- Parameters:
- Xsequence of float, 2-d sequence of float
CDF input(s).
- Returns:
- Ffloat,
Point
CDF value(s) at input(s) .
- Ffloat,
Notes
The cumulative distribution function is defined as:
- computeCDFGradient(*args)¶
Compute the gradient of the cumulative distribution function.
- Parameters:
- Xsequence of float
CDF input.
- Returns:
- dFdtheta
Point
Partial derivatives of the CDF with respect to the distribution parameters at input .
- dFdtheta
- computeCharacteristicFunction(*args)¶
Compute the characteristic function.
- Parameters:
- tfloat
Characteristic function input.
- Returns:
- phicomplex
Characteristic function value at input .
Notes
The characteristic function is defined as:
OpenTURNS features a generic implementation of the characteristic function for all its univariate distributions (both continuous and discrete). This default implementation might be time consuming, especially as the modulus of gets high. Only some univariate distributions benefit from dedicated more efficient implementations.
- computeComplementaryCDF(*args)¶
Compute the complementary cumulative distribution function.
- Parameters:
- Xsequence of float, 2-d sequence of float
Complementary CDF input(s).
- Returns:
- Cfloat,
Point
Complementary CDF value(s) at input(s) .
- Cfloat,
See also
Notes
The complementary cumulative distribution function.
Warning
This is not the survival function (except for 1-dimensional distributions).
- computeConditionalCDF(*args)¶
Compute the conditional cumulative distribution function.
- Parameters:
- Xnfloat, sequence of float
Conditional CDF input (last component).
- Xcondsequence of float, 2-d sequence of float with size
Conditionning values for the other components.
- Returns:
- Ffloat, sequence of float
Conditional CDF value(s) at input , .
Notes
The conditional cumulative distribution function of the last component with respect to the other fixed components is defined as follows:
- computeConditionalDDF(x, y)¶
Compute the conditional derivative density function of the last component.
With respect to the other fixed components.
- Parameters:
- Xnfloat
Conditional DDF input (last component).
- Xcondsequence of float with dimension
Conditionning values for the other components.
- Returns:
- dfloat
Conditional DDF value at input , .
See also
- computeConditionalPDF(*args)¶
Compute the conditional probability density function.
Conditional PDF of the last component with respect to the other fixed components.
- Parameters:
- Xnfloat, sequence of float
Conditional PDF input (last component).
- Xcondsequence of float, 2-d sequence of float with size
Conditionning values for the other components.
- Returns:
- Ffloat, sequence of float
Conditional PDF value(s) at input , .
See also
- computeConditionalQuantile(*args)¶
Compute the conditional quantile function of the last component.
Conditional quantile with respect to the other fixed components.
- Parameters:
- pfloat, sequence of float,
Conditional quantile function input.
- Xcondsequence of float, 2-d sequence of float with size
Conditionning values for the other components.
- Returns:
- X1float
Conditional quantile at input , .
See also
- computeDDF(*args)¶
Compute the derivative density function.
- Parameters:
- Xsequence of float, 2-d sequence of float
PDF input(s).
- Returns:
Notes
The derivative density function is the gradient of the probability density function with respect to :
- computeDensityGenerator(betaSquare)¶
Compute the probability density function of the characteristic generator.
PDF of the characteristic generator of the elliptical distribution.
- Parameters:
- beta2float
Density generator input.
- Returns:
- pfloat
Density generator value at input .
See also
Notes
This is the function such that the probability density function rewrites:
This function only exists for elliptical distributions.
- computeDensityGeneratorDerivative(betaSquare)¶
Compute the first-order derivative of the probability density function.
PDF of the characteristic generator of the elliptical distribution.
- Parameters:
- beta2float
Density generator input.
- Returns:
- pfloat
Density generator first-order derivative value at input .
See also
Notes
This function only exists for elliptical distributions.
- computeDensityGeneratorSecondDerivative(betaSquare)¶
Compute the second-order derivative of the probability density function.
PDF of the characteristic generator of the elliptical distribution.
- Parameters:
- beta2float
Density generator input.
- Returns:
- pfloat
Density generator second-order derivative value at input .
See also
Notes
This function only exists for elliptical distributions.
- computeEntropy()¶
Compute the entropy of the distribution.
- Returns:
- efloat
Entropy of the distribution.
Notes
The entropy of a distribution is defined by:
Where the random vector follows the probability distribution of interest, and is either the probability density function of if it is continuous or the probability distribution function if it is discrete.
- computeGeneratingFunction(*args)¶
Compute the probability-generating function.
- Parameters:
- zfloat or complex
Probability-generating function input.
- Returns:
- gfloat
Probability-generating function value at input .
See also
Notes
The probability-generating function is defined as follows:
This function only exists for discrete distributions. OpenTURNS implements this method for univariate distributions only.
- computeInverseSurvivalFunction(point)¶
Compute the inverse survival function.
- Parameters:
- pfloat,
Level of the survival function.
- Returns:
- x
Point
Point such that with iso-quantile components.
- x
See also
Notes
The inverse survival function writes: where . OpenTURNS returns the point such that .
- computeLogCharacteristicFunction(*args)¶
Compute the logarithm of the characteristic function.
- Parameters:
- tfloat
Characteristic function input.
- Returns:
- phicomplex
Logarithm of the characteristic function value at input .
See also
Notes
OpenTURNS features a generic implementation of the characteristic function for all its univariate distributions (both continuous and discrete). This default implementation might be time consuming, especially as the modulus of gets high. Only some univariate distributions benefit from dedicated more efficient implementations.
- computeLogGeneratingFunction(*args)¶
Compute the logarithm of the probability-generating function.
- Parameters:
- zfloat or complex
Probability-generating function input.
- Returns:
- lgfloat
Logarithm of the probability-generating function value at input .
See also
Notes
This function only exists for discrete distributions. OpenTURNS implements this method for univariate distributions only.
- computeLogPDF(*args)¶
Compute the logarithm of the probability density function.
- Parameters:
- Xsequence of float, 2-d sequence of float
PDF input(s).
- Returns:
- ffloat,
Point
Logarithm of the PDF value(s) at input(s) .
- ffloat,
- computeLogPDFGradient(*args)¶
Compute the gradient of the log probability density function.
- Parameters:
- Xsequence of float
PDF input.
- Returns:
- dfdtheta
Point
Partial derivatives of the logPDF with respect to the distribution parameters at input .
- dfdtheta
- computeLowerExtremalDependenceMatrix()¶
Compute the lower extremal dependence coefficients.
We assume that the distribution is -dimensional, with and that its copula is denoted by . The lower extremal dependence matrix is where is the lower extremal dependence coefficient of the bivariate distribution . It is defined by:
where is the lower extremal dependence function of the bivariate distribution defined by:
Refer to Tail dependence coefficients to get more details.
- Returns:
- dep
CorrelationMatrix
The dependence matrix.
- dep
Examples
>>> import openturns as ot >>> copula = ot.FrankCopula() >>> chiLb = copula.computeLowerExtremalDependenceMatrix()[1, 0]
- computeLowerTailDependenceMatrix()¶
Compute the lower tail dependence coefficients.
We assume that the distribution is -dimensional, with and that its copula is denoted by . The lower tail dependence matrix is