Parent Distribution Class
Methods
- class Distribution(ordered_parameters=None, **kwargs)[source]
A parent class to all
Distribution
classes.All distributions possess a number of methods to perform basic probabilistic operations. For most of the predefined distributions in
UQpy
these methods are inherited from thescipy.stats
package. 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
Distribution
objects possessesget_parameters()
andupdate_parameters()
methods. These are described in more detail below.Any
Distribution
further 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 certainDistribution
objects such as those of typeJointIndependent
orJointCopula
. The user is advised to use theget_parameters()
method to access the parameters.
- update_parameters(**kwargs)[source]
Update the parameters of a
Distribution
object.To update the parameters of a
JointIndependent
or aJointCopula
distribution, each parameter is assigned a unique string identifier askey_index
- wherekey
is the parameter name andindex
the 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
Distribution
object.To update the parameters of a
JointIndependent
or aJointCopula
distribution, each parameter is assigned a unique string identifier askey_index
- wherekey
is the parameter name andindex
the 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
Distribution
objects such as those of typeJointIndependent
orJointCopula
. 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.ndarray
of shape(npoints, dimension)
.- Returns:
Evaluated cdf values,
numpy.ndarray
of 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.ndarray
of shape(npoints, dimension)
.- Returns:
Evaluated pdf values,
numpy.ndarray
of 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.ndarray
of shape(npoints, dimension)
.- Returns:
Evaluated pmf values,
numpy.ndarray
of 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.ndarray
of shape(npoints, dimension)
.- Returns:
Evaluated log-pdf values,
numpy.ndarray
of 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.ndarray
of shape(npoints, dimension)
.- Returns:
Evaluated log-pmf values,
numpy.ndarray
of 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.ndarray
of 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 anint
is 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.stats
package.
- Parameters:
data – Data array, must be
numpy.ndarray
of shape(npoints, dimension)
.- Returns:
Maximum-likelihood parameter estimates.
- Return type: