Histogram distribution

(Source code, png)

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

Histogram distribution.

Available constructors:

Histogram(first, width, height)

Histogram(ticks, frequencies)

Parameters:
firstfloat

Lower bound of the range.

Default value is zero.

widthpositive sequence of float

w_i is the width of the class i for 1 \leq i \leq n.

Default value is 1.

heightpositive sequence of float

h_i is the density of the class i for 1 \leq i \leq n. The h_i are automatically normalized such that \sum_{i=1}^n h_iw_i=1.

Default value is 1.

ticksincreasing sequence of float

t_0 is the lower bound of the first class and t_i is the upper bound of the class i for 1 \leq i \leq n

Default value is (0.0, 1.0).

frequenciespositive sequence of float

f_i is the probability of the class i for 1 \leq i \leq n. The f_i are automatically normalized such that \sum_{i=1}^n f_i=1.

Default value is 1.0.

Notes

Its probability distribution function is defined as:

f_X(x) = \sum_{i=1}^{n}h_i\;\boldsymbol{1}_{[x_{i-1},x_i]}(x)

where the class i is [x_{i-1},x_i] and w_i = x_i - x_{i-1}. The values h_i are such that \sum_{i=1}^n h_iw_i=1. The relation between the two parameterizations are:

\begin{eqnarray*}
    first & = & t_0 \\
    w_i & = & x_i - x_{i-1} \\
    h_i & = & f_i / w_i
\end{eqnarray*}

Its first moments are:

\begin{eqnarray*}
    \Expect{X} & = & \frac{1}{2}
                     \sum_{i=1}^n h_i\,w_i (x_{i+1} + x_i)\\
    \Var{X} & = & \frac{1}{3}
                  \sum_{i=1}^n h_i\,w_i (x_{i+1}^2 + x_i\,x_{i+1} + x_i^2)
\end{eqnarray*}

Examples

Create a distribution:

>>> import openturns as ot
>>> l = [1.0, 0.7, 1.2, 0.9]
>>> h = [0.5, 1.5, 3.5, 2.5]
>>> distribution = ot.Histogram(-1.5, l, h)

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.

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.

getFirst()

Accessor to the distribution's lower bound.

getHeight()

Accessor to the height.

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.

getWidth()

Accessor to the width.

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.

setData(width, weight)

Accessor to the widths and heights.

setDescription(description)

Accessor to the componentwise description.

setFirst(first)

Accessor to the lower bound.

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: