Uniform distribution

(Source code, png)

../../_images/openturns-Uniform-1.png
class Uniform(*args)

Uniform distribution.

Parameters:
afloat

Lower bound.

Default value is -1.0.

bfloat, b > a

Upper bound.

Default value is 1.0.

Notes

Its probability density function is defined as:

f_X(x) = \frac{1}{b-a}, \quad x \in [a; b]

with a < b.

Its first moments are defined as:

\begin{eqnarray*}
    \Expect{X} & = & \frac{a+b}{2} \\
    \Var{X} & = & \frac{(b-a)^2}{12}
\end{eqnarray*}

Examples

Create a distribution:

>>> import openturns as ot
>>> distribution = ot.Uniform(2.0, 3.0)

Create it from the alternative parametrization (\mu, \sigma):

>>> distribution2 = ot.UniformMuSigma(3.0, 1.15).getDistribution()

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.

computeBilateralConfidenceInterval(prob)

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.

computeCharacteristicFunction(x)

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.

computeEntropy()

Compute the entropy of the distribution.

computeGeneratingFunction(*args)

Compute the probability-generating function.

computeInverseSurvivalFunction(point)

Compute the inverse survival function.

computeLogCharacteristicFunction(*args)

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.

computeLowerExtremalDependenceMatrix()

Compute the lower extremal dependence coefficients.

computeLowerTailDependenceMatrix()

Compute the lower tail dependence coefficients.

computeMinimumVolumeInterval(prob)

Compute the confidence interval with minimum volume.

computeMinimumVolumeIntervalWithMarginalProbability(prob)

Compute the confidence interval with minimum volume.

computeMinimumVolumeLevelSet(prob)

Compute the confidence domain with minimum volume.

computeMinimumVolumeLevelSetWithThreshold(prob)

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.

computeSequentialConditionalCDF(x)

Compute the sequential conditional cumulative distribution functions.

computeSequentialConditionalDDF(x)

Compute the sequential conditional derivative density function.

computeSequentialConditionalPDF(x)

Compute the sequential conditional probability density function.

computeSequentialConditionalQuantile(q)

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.

computeUpperExtremalDependenceMatrix()

Compute the upper extremal dependence coefficients.

computeUpperTailDependenceMatrix()

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.

drawLowerExtremalDependenceFunction()

Draw the lower extremal dependence function.

drawLowerTailDependenceFunction()

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.

drawUpperExtremalDependenceFunction()

Draw the upper extremal dependence function.

drawUpperTailDependenceFunction()

Draw the upper tail dependence function.

exp()

Transform distribution by exponential function.

getA()

Accessor to the distribution's lower bound.

getB()

Accessor to the distribution's upper bound.

getCDFEpsilon()

Accessor to the CDF computation precision.

getCentralMoment(n)

Accessor to the componentwise central moments.

getCholesky()

Accessor to the Cholesky factor of the covariance matrix.

getClassName()

Accessor to the object's name.

getCopula()

Accessor to the copula of the distribution.

getCorrelation()

Accessor to the correlation matrix.

getCovariance()

Accessor to the covariance matrix.

getDescription()

Accessor to the componentwise description.

getDimension()

Accessor to the dimension of the distribution.

getDispersionIndicator()

Dispersion indicator accessor.

getIntegrationNodesNumber()

Accessor to the number of Gauss integration points.

getInverseCholesky()

Accessor to the inverse Cholesky factor of the covariance matrix.

getInverseIsoProbabilisticTransformation()

Accessor to the inverse iso-probabilistic transformation.

getIsoProbabilisticTransformation()

Accessor to the iso-probabilistic transformation.

getKendallTau()

Accessor to the Kendall coefficients matrix.

getKurtosis()

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.

getPDFEpsilon()

Accessor to the PDF computation precision.

getParameter()

Accessor to the parameter of the distribution.

getParameterDescription()

Accessor to the parameter description of the distribution.

getParameterDimension()

Accessor to the number of parameters in the distribution.

getParametersCollection()

Accessor to the parameter of the distribution.

getPearsonCorrelation()

Accessor to the Pearson correlation matrix.

getPositionIndicator()

Position indicator accessor.

getProbabilities()

Accessor to the discrete probability levels.

getRange()

Accessor to the range of the distribution.

getRealization()

Accessor to a pseudo-random realization from the distribution.

getRoughness()

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.

getShapeMatrix()

Accessor to the shape matrix of the underlying copula if it is elliptical.

getShiftedMoment(n, shift)

Accessor to the componentwise shifted moments.

getSingularities()

Accessor to the singularities of the PDF function.

getSkewness()

Accessor to the componentwise skewness.

getSpearmanCorrelation()

Accessor to the Spearman correlation matrix.

getStandardDeviation()

Accessor to the componentwise standard deviation.

getStandardDistribution()

Accessor to the standard distribution.

getStandardRepresentative()

Accessor to the standard representative distribution in the parametric family.

getSupport(*args)

Accessor to the support of the distribution.

hasEllipticalCopula()

Test whether the copula of the distribution is elliptical or not.

hasIndependentCopula()

Test whether the copula of the distribution is the independent one.

hasName()

Test if the object is named.

inverse()

Transform distribution by inverse function.

isContinuous()

Test whether the distribution is continuous or not.

isCopula()

Test whether the distribution is a copula or not.

isDiscrete()

Test whether the distribution is discrete or not.

isElliptical()

Test whether the distribution is elliptical or not.

isIntegral()

Test whether the distribution is integer-valued or not.

ln()

Transform distribution by natural logarithm function.

log()

Transform distribution by natural logarithm function.

setA(a)

Accessor to the distribution's lower bound.

setB(b)

Accessor to the distribution's upper bound.

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.

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:
distDistribution

The transformed distribution.

acos()

Transform distribution by arccosine function.

Returns:
distDistribution

The transformed distribution.

acosh()

Transform distribution by acosh function.

Returns:
distDistribution

The transformed distribution.

asin()

Transform distribution by arcsine function.

Returns:
distDistribution

The transformed distribution.

asinh()

Transform distribution by asinh function.

Returns:
distDistribution

The transformed distribution.

atan()

Transform distribution by arctangent function.

Returns:
distDistribution

The transformed distribution.

atanh()

Transform distribution by atanh function.

Returns:
distDistribution

The transformed distribution.

cbrt()

Transform distribution by cubic root function.

Returns:
distDistribution

The transformed distribution.

computeBilateralConfidenceInterval(prob)

Compute a bilateral confidence interval.

Parameters:
alphafloat, \alpha \in [0,1]

The confidence level.

Returns:
confIntervalInterval

The confidence interval of level alpha.

Notes

We consider an absolutely continuous measure \mu with density function p.

The bilateral confidence interval I^*_{\alpha} is the Cartesian product I^*_{\alpha} = [a_1, b_1] \times \dots \times [a_d, b_d] such that there exists \beta \in [0,1] which satisfies the equations a_i = F_i^{-1}((1 - \beta) / 2) and b_i = F_i^{-1}((1 + \beta) / 2) for all i and \mu(I^*_{\alpha}) = \alpha.

Examples

We consider a Normal(2) distribution with zero mean, unit standard deviation and independent components. We note \Phi_2 its cdf. Due to symetries of the distribution, the bilateral confidence interval is I^*_{\alpha} = [-a, a] \times \times [-a, a] where a = \Phi^{-1}((1+\beta)/2) where \Phi is the marginal cdf of each component. Then \beta is such that \Phi_2(I^*_{\alpha}) = \alpha. As \Phi_2(I^*_{\alpha}) = (2\Phi(a) - 1)^2 = _beta^2, then, \beta is equal to \beta = \sqrt{\alpha} \simeq 0.9486 and a \simeq -1.9488.

>>> 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, \alpha \in [0,1]

The confidence level.

Returns:
confIntervalInterval

The confidence interval of level alpha.

betafloat

The probability \beta.

Examples

We consider a Normal(2) distribution with zero mean, unit standard deviation and independent components. We note \Phi_2 its cdf. Due to symetries of the distribution, the bilateral confidence interval is I^*_{\alpha} = [-a, a] \times [-a, a] where a = \Phi^{-1}((1 + \beta) / 2) where \Phi is the marginal cdf of each 1D marginal standard Gaussian component. Then \beta is such that \Phi_2(I^*_{\alpha}) = \alpha. As \Phi_2(I^*_{\alpha}) = (2\Phi(a) - 1)^2 = \beta^2, then, \beta is equal to \beta = \sqrt{\alpha} = 0.9486 and a = -1.9488 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 \Rset^d.

Returns:
Ffloat, Point

CDF value at x.

Notes

The cumulative distribution function is defined as:

F_{\vect{X}}(\vect{x}) = \Prob{\bigcap_{i=1}^n X_i \leq x_i},
                         \quad \vect{x} \in \Rset^d

computeCDFGradient(*args)

Compute the gradient of the cumulative distribution function.

Parameters:
xsequence of float

Point in \Rset^d.

Returns:
dFdthetaPoint

Partial derivatives of the CDF with respect to the distribution parameters at x.

computeCharacteristicFunction(x)

Compute the characteristic function.

Parameters:
tfloat

Characteristic function input.

Returns:
phicomplex

Characteristic function value at input t.

Notes

The characteristic function is defined as:

\phi_X(t) = \mathbb{E}\left[\exp(- i t X)\right],
            \quad t \in \Rset

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 t 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 \Rset^d.

Returns:
Cfloat, Point

Complementary CDF value at x.

Notes

The complementary cumulative distribution function.

1 - F_{\vect{X}}(\vect{x}) = 1 - \Prob{\bigcap_{i = 1}^d \left\{X_i \leq x_i \right\}}, \qquad \vect{x} \in \Rset^d

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 j-1, j \leq d

Conditioning values for the components (X_{1}, \dots, X_{j-1}).

Returns:
pfloat, sequence of float

Conditional CDF value at xj given xcond.

Notes

Let \vect{X} be a random vector of dimension d. The conditional cumulative distribution function of the component X_j given that the components of indices k \leq j-1 are fixed to (x_1, \dots, x_{j-1}) is defined by:

F_{X_j \mid X_1, \ldots, X_{j - 1}}(x_j; x_1, \dots, x_{j-1}) =
    \Prob{X_j \leq x_j \mid X_1=x_1, \ldots, X_{j-1}=x_{j-1}}.

For j=1, it reduces to F_{X_1}(x_1).

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 j-1, j \leq d

Conditioning values for the components (X_{1}, \dots, X_{j-1}).

Returns:
ddffloat,

Conditional DDF value at xj given xcond.

Notes

Let \vect{X} be a random vector of dimension d. The conditional derivative density function of the component X_j given that the components of indices k \leq j-1 are fixed to (x_1, \dots, x_{j-1}) is defined by:

\dfrac{d^2}{d\,x_j^2}F_{X_j \mid X_1, \ldots, X_{j - 1}}(x_j; x_1, \dots, x_{j-1})

where for 2 \leq j \leq d:

F_{X_j \mid X_1, \ldots, X_{j - 1}}(x_j; x_1, \dots, x_{j-1}) =
\Prob{X_j \leq x_j \mid X_1=x_1, \ldots, X_{j-1}=x_{j-1}}.

For j=1, it reduces to \dfrac{d^2}{d\,x_1^2}F_{X_1}(x_1), ie the DDF of the first component at x_1.

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 j-1, j \leq d

Conditioning values for the components (X_{1}, \dots, X_{j-1}).

Returns:
cpdffloat, sequence of float

Conditional PDF at xd, given xcond.

Notes

Let \vect{X} be a random vector of dimension d. The conditional probability density function of the component X_j given that the components of indices k \leq j-1 are fixed to (x_1, \dots, x_{j-1}) is defined by:

\dfrac{d}{d\,x_j}F_{X_j \mid X_1, \ldots, X_{j - 1}}(x_j; x_1, \dots, x_{j-1})

where for 2 \leq j \leq d:

F_{X_j \mid X_1, \ldots, X_{j - 1}}(x_j; x_1, \dots, x_{j-1}) =
\Prob{X_j \leq x_j \mid X_1=x_1, \ldots, X_{j-1}=x_{j-1}}.

For j=1, it reduces to \dfrac{d}{d\,x_1}F_{X_1}(x_1).

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, p \in [0, 1]

Conditional quantile.

xcondsequence of float, 2-d sequence of float with size j-1, j \leq d

Conditioning values for the components (X_{1}, \dots, X_{j-1}).

Returns:
xjfloat

Conditional quantile of order p of the component X_j given that the components of indices k \leq j-1 are fixed and equal to xcond.

Notes

Let \vect{X} be a random vector of dimension d. The conditional quantile of order p of the component X_j given that the components of indices k \leq j-1 are fixed to (x_1, \dots, x_{j-1}) is defined by:

F^{-1}_{X_j \mid X_1, \ldots, X_{j - 1}}(p; x_1, \dots, x_{j-1})

where F^{-1} is the quantile function. For j=1, it reduces to F^{-1}_{X_1}(p).

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:
ddfPoint, Sample

DDF value at x.

Notes

The derivative density function is the gradient of the probability density function with respect to \vect{x}:

\vect{\nabla}_{\vect{x}} f_{\vect{X}}(\vect{x}) =
    \Tr{\left(\frac{\partial f_{\vect{X}}(\vect{x})}{\partial x_1},
             \dots, \frac{\partial f_{\vect{X}}(\vect{x})}{\partial x_d}\right)},
    \quad \vect{x} \in \Rset^d

computeEntropy()

Compute the entropy of the distribution.

Returns:
efloat

Entropy of the distribution.

Notes

The entropy of a distribution is defined by:

\cE_X = \Expect{-\log(p_X(\vect{X}))}

Where the random vector \vect{X} follows the probability distribution of interest, and p_X is either the probability density function of \vect{X} 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 z.

See also

isDiscrete

Notes

The probability-generating function is defined as follows:

G_X(z) = \Expect{z^X}, \quad z \in \Cset

This function only exists for discrete distributions. OpenTURNS implements this method for univariate distributions only.

computeInverseSurvivalFunction(point)

Compute the inverse survival function.

Parameters:
pfloat, p \in [0; 1]

Value of the survival function.

Returns:
xPoint

Point \vect{x} such that S_{\vect{X}}(\vect{x}) = p with iso-quantile components.

Notes

Among the points \vect{x} that satisfy