Parent Distribution Class
Methods
- class Distribution(ordered_parameters=None, **kwargs)[source]
A parent class to all
Distributionclasses.All distributions possess a number of methods to perform basic probabilistic operations. For most of the predefined distributions in
UQpythese methods are inherited from thescipy.statspackage. These include standard operations such as computing probability density/mass functions, cumulative distribution functions and their inverse, drawing random samples, computing moments and parameter fitting. However, for user-defined distributions, any desired method can be constructed into the child class structure.For bookkeeping purposes, all
Distributionobjects possessesget_parameters()andupdate_parameters()methods. These are described in more detail below.Any
Distributionfurther inherits from one of the following classes:DistributionContinuous1D: Parent class to 1-dimensional continuous probability distributions.DistributionDiscrete1D: Parent class to 1-dimensional discrete probability distributions.DistributionND: Parent class to multivariate probability distributions.
- Parameters:
ordered_parameters (
Optional[list]) – Ordered list of parameter names, useful when parameter values are stored in vectors and must be passed to theupdate_parameters()method.kwargs (
dict) – Parameters of the distribution. Note: this attribute is not defined for certainDistributionobjects such as those of typeJointIndependentorJointCopula. The user is advised to use theget_parameters()method to access the parameters.
- update_parameters(**kwargs)[source]
Update the parameters of a
Distributionobject.To update the parameters of a
JointIndependentor aJointCopuladistribution, each parameter is assigned a unique string identifier askey_index- wherekeyis the parameter name andindexthe index of the marginal (e.g., location parameter of the 2nd marginal is identified asloc_1).- Parameters:
kwargs (
dict) – Parameters to be updated, designated by their respective keywords.
- get_parameters()[source]
Return the parameters of a
Distributionobject.To update the parameters of a
JointIndependentor aJointCopuladistribution, each parameter is assigned a unique string identifier askey_index- wherekeyis the parameter name andindexthe index of the marginal (e.g., location parameter of the 2nd marginal is identified asloc_1).- Returns:
Parameters of the distribution.
Attributes
-
Distribution.parameters:
dict Ordered list of parameter names, useful when parameter values are stored in vectors and must be passed to the
update_params()method.
-
Distribution.ordered_parameters:
list Parameters of the distribution.
This attribute is not defined for certain
Distributionobjects such as those of typeJointIndependentorJointCopula. The user is advised to use theget_parameters()method to access the parameters.
Additional methods available from scipy.stats :
- cdf(x)
Evaluate the cumulative distribution function.
- Parameters:
x – Point(s) at which to evaluate the
cdf(), must benumpy.ndarrayof shape(npoints, dimension).- Returns:
Evaluated cdf values,
numpy.ndarrayof shape(npoints,).
- pdf(x)
Evaluate the probability density function of a continuous or multivariate mixed continuous-discrete distribution.
- Parameters:
x – Point(s) at which to evaluate the
pdf(), must benumpy.ndarrayof shape(npoints, dimension).- Returns:
Evaluated pdf values,
numpy.ndarrayof shape(npoints,).
- pmf(x)
Evaluate the probability mass function of a discrete distribution.
- Parameters:
x – Point(s) at which to evaluate the
pmf(), must benumpy.ndarrayof shape(npoints, dimension).- Returns:
Evaluated pmf values,
numpy.ndarrayof shape(npoints,).
- log_pdf(x)
Evaluate the logarithm of the probability density function of a continuous or multivariate mixed continuous-discrete distribution.
- Parameters:
x – Point(s) at which to evaluate the
log_pdf(), must benumpy.ndarrayof shape(npoints, dimension).- Returns:
Evaluated log-pdf values,
numpy.ndarrayof shape(npoints,).
- log_pmf(x)
Evaluate the logarithm of the probability mass function of a discrete distribution.
- Parameters:
x – Point(s) at which to evaluate the
log_pmf(), must benumpy.ndarrayof shape(npoints, dimension).- Returns:
Evaluated log-pmf values,
numpy.ndarrayof shape(npoints,).
- icdf(x)
Evaluate the inverse cumulative distribution function for univariate distributions.
- Parameters:
x – Point(s) at which to evaluate the
icdf(), must be of shape(npoints, dimension).- Returns:
Evaluated icdf values,
numpy.ndarrayof shape(npoints,).- Return type:
- rvs(nsamples=1, random_state=None)
Sample independent identically distributed (iid) realizations.
- Parameters:
nsamples – Number of iid samples to be drawn. Default is 1.
random_state – Random seed used to initialize the pseudo-random number generator. Default is
None. If anintis provided, this sets the seed for an object ofnumpy.random.RandomState. Otherwise, the object itself can be passed directly.- Returns:
Generated iid samples, :class:`numpy.ndarray of shape
(npoints, dimension).
- moments(moments2return='mvsk')
Computes the mean (‘m’), variance/covariance (‘v’), skewness (‘s’) and/or kurtosis (‘k’) of the distribution. For a univariate distribution, mean, variance, skewness and kurtosis are returned. For a multivariate distribution, the mean vector, covariance and vectors of marginal skewness and marginal kurtosis are returned.
- Parameters:
moments2return – Indicates which moments are to be returned (mean, variance, skewness and/or kurtosis). Default is ‘mvsk’.
- Returns:
mean: mean,var: variance/covariance,skew: skewness,kurt: kurtosis.- Return type:
- fit(data)
Compute the maximum-likelihood parameters from iid data. Computes the mle analytically if possible. For univariate continuous distributions, it leverages the fit method of the
scipy.statspackage.
- Parameters:
data – Data array, must be
numpy.ndarrayof shape(npoints, dimension).- Returns:
Maximum-likelihood parameter estimates.
- Return type: