UserDefined distribution¶
(Source code
, png
)
- class UserDefined(*args)¶
UserDefined distribution.
Available constructors:
UserDefined(points)
UserDefined(points, weights)
- Parameters:
- points2-d sequence of float
List of points of dimension , .
Default value is [1].
- weightssequence of float
List of weights , . If , the weights are normalized.
Default value is [1].
Notes
Its probability distribution function is defined as:
Its first moment is:
Sampling is done using the alias method as described in [devroye1986], Chapter 3. It has an optimal space complexity of and runtime CPU complexity of , see
rDiscrete()
.Examples
Create a 1d-distribution:
>>> import openturns as ot >>> points = ot.Sample([[1.0], [2.0], [3.0]]) >>> weights = [0.4, 0.5, 1.0] >>> my_distribution = ot.UserDefined(points, weights) >>> print(my_distribution) UserDefined({x = [1], p = 0.210526}, {x = [2], p = 0.263158}, {x = [3], p = 0.526316})
Create a 3d-distribution:
>>> points = ot.Sample(4, 3) >>> for i in range(4): ... for j in range(3): ... points[i, j] = 10 * (i + 1) + 0.1 * (j + 1) >>> distribution = ot.UserDefined(points, [0.3,0.2,0.25,0.25]) >>> print(distribution) UserDefined({x = [10.1,10.2,10.3], p = 0.3}, {x = [20.1,20.2,20.3], p = 0.2}, {x = [30.1,30.2,30.3], p = 0.25}, {x = [40.1,40.2,40.3], p = 0.25})
Create , the discrete uniform distribution on the set {9, 10, …, 19} with equal weights:
>>> points = [[i] for i in range(9, 20)] >>> distribution = ot.UserDefined(points)
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.
compactSupport
(*args)Compact the support of the distribution.
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.
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.
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.
Accessor to the copula of the distribution.
Accessor to the correlation matrix.
Accessor to the covariance matrix.
Accessor to the componentwise description.
Accessor to the dimension of the distribution.
Dispersion indicator accessor.
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.
getMean
()Accessor to the mean.
getMoment
(n)Accessor to the componentwise moments.
getName
()Accessor to the object's name.
getP
()Accessor to the distribution's parameter.
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.
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 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 support tolerance.
getX
()Accessor to the distribution's parameter.
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.
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.
setData
(points, weights)Accessor to the distribution's and parameters.
setDescription
(description)Accessor to the componentwise description.
setIntegrationNodesNumber
(integrationNodesNumber)Accessor to the number of Gauss integration points.
setName
(name)Accessor to the object's name.
setParameter
(parameter)Accessor to the parameter of the distribution.
setParametersCollection
(*args)Accessor to the parameter of the distribution.
setSupportEpsilon
(epsilon)Accessor to the support tolerance.
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.
- __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
- compactSupport(*args)¶
Compact the support of the distribution.
Compact by concatenating points of distance less than and adding their weights.
Notes
The has a default value associated to the
ResourceMap
key DiscreteDistribution-SupportEpsilon.The method is always used for any univariate distributions and for upper dimensions, it is only used when the number of points defining the support is less than a limit specified by the
ResourceMap
key UserDefined-SmallSize. By default, the size limit is equal to .
- computeBilateralConfidenceInterval(prob)¶
Compute a bilateral confidence interval.
- Parameters:
- alphafloat,
The confidence level.
- Returns:
- confInterval
Interval
The confidence interval of level alpha.
- confInterval
Notes
We consider an absolutely continuous measure with density function .
The bilateral confidence interval is the Cartesian product such that there exists which satisfies the equations and for all and .
Examples
We consider a Normal(2) distribution with zero mean, unit standard deviation and independent components. We note its cdf. Due to symetries of the distribution, the bilateral confidence interval is where where is the marginal cdf of each component. Then is such that . As , then, is equal to and .
>>> import openturns as ot >>> dist = ot.Normal(2) >>> confInt = dist.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 alpha.
- betafloat
The probability .
- confInterval
Examples
We consider a Normal(2) distribution with zero mean, unit standard deviation and independent components. We note its cdf. Due to symetries of the distribution, the bilateral confidence interval is where where is the marginal cdf of each 1D marginal standard Gaussian component. Then is such that . As , then, is equal to and with 4 significant digits.
>>> import openturns as ot >>> dist = ot.Normal(2) >>> confInt, beta = dist.computeBilateralConfidenceIntervalWithMarginalProbability(0.9)
- computeCDF(*args)¶
Compute the cumulative distribution function.
- Parameters:
- xsequence of float, 2-d sequence of float
Point in .
- Returns:
- Ffloat,
Point
CDF value at x.
- Ffloat,
Notes
The cumulative distribution function is defined as:
- computeCDFGradient(*args)¶
Compute the gradient of the cumulative distribution function.
- Parameters:
- xsequence of float
Point in .
- Returns:
- dFdtheta
Point
Partial derivatives of the CDF with respect to the distribution parameters at x.
- dFdtheta
- computeCharacteristicFunction(*args)¶
Compute the characteristic function.
- Parameters:
- tfloat
Characteristic function input.
- Returns:
- phicomplex
Characteristic function value at input t.
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
Point in .
- Returns:
- Cfloat,
Point
Complementary CDF value at x.
- Cfloat,
See also
Notes
The complementary cumulative distribution function.
Warning
The complementary CDF is different from the survival function (except for scalar distributions).
- computeConditionalCDF(*args)¶
Compute the conditional cumulative distribution function.
- Parameters:
- xjfloat, sequence of float
Conditional CDF input.
- xcondsequence of float, 2-d sequence of float with size ,
Conditioning values for the components .
- Returns:
- pfloat, sequence of float
Conditional CDF value at xj given xcond.
Notes
Let be a random vector of dimension . The conditional cumulative distribution function of the component given that the components of indices are fixed to is defined by:
For , it reduces to .
- computeConditionalDDF(x, y)¶
Compute the conditional derivative density function of the last component.
With respect to the other fixed components.
- Parameters:
- xjfloat, sequence of float
Conditional CDF input.
- xcondsequence of float, 2-d sequence of float with size ,
Conditioning values for the components .
- Returns:
- ddffloat,
Conditional DDF value at xj given xcond.
See also
Notes
Let be a random vector of dimension . The conditional derivative density function of the component given that the components of indices are fixed to is defined by:
where for :
For , it reduces to , ie the DDF of the first component at .
- computeConditionalPDF(*args)¶
Compute the conditional probability density function.
Conditional PDF of the last component with respect to the other fixed components.
- Parameters:
- xjfloat, sequence of float,
Conditional CDF input.
- xcondsequence of float, 2-d sequence of float with size ,
Conditioning values for the components .
- Returns:
- cpdffloat, sequence of float
Conditional PDF at xd, given xcond.
See also
Notes
Let be a random vector of dimension . The conditional probability density function of the component given that the components of indices are fixed to is defined by:
where for :
For , it reduces to .
- 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.
- xcondsequence of float, 2-d sequence of float with size ,
Conditioning values for the components .
- Returns:
- xjfloat
Conditional quantile of order p of the component given that the components of indices are fixed and equal to xcond.
See also
Notes
Let be a random vector of dimension . The conditional quantile of order of the component given that the components of indices are fixed to is defined by:
where is the quantile function. For , it reduces to .
- computeDDF(*args)¶
Compute the derivative density function.
- Parameters:
- xsequence of float, 2-d sequence of float
The input value where the conditional derivative density function must be evaluated.
- Returns:
Notes
The derivative density function is the gradient of the probability density function with respect to :
- 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