chaospy.MvNormal

class chaospy.MvNormal(mu, sigma=None, rotation=None)[source]

Multivariate Normal Distribution.

Args:
mu (float, numpy.ndarray):

Mean vector

scale (float, numpy.ndarray):

Covariance matrix or variance vector if scale is a 1-d vector.

rotation (Sequence[int]):

The order of which to resolve conditionals. Defaults to range(len(distribution)) which is the same as p(x0), p(x1|x0), p(x2|x0,x1), ….

Examples:
>>> distribution = chaospy.MvNormal([10, 20, 30],
...     [[1, 0.2, 0.3], [0.2, 2, 0.4], [0.3, 0.4, 1]], rotation=[1, 2, 0])
>>> distribution  
MvNormal(mu=[10, 20, 30],
         sigma=[[1, 0.2, 0.3], [0.2, 2, 0.4], [0.3, 0.4, 1]])
>>> chaospy.E(distribution)
array([10., 20., 30.])
>>> chaospy.Cov(distribution)
array([[1. , 0.2, 0.3],
       [0.2, 2. , 0.4],
       [0.3, 0.4, 1. ]])
>>> mesh = numpy.mgrid[:2, :2, :2].reshape(3, -1)*.5+.1
>>> mesh
array([[0.1, 0.1, 0.1, 0.1, 0.6, 0.6, 0.6, 0.6],
       [0.1, 0.1, 0.6, 0.6, 0.1, 0.1, 0.6, 0.6],
       [0.1, 0.6, 0.1, 0.6, 0.1, 0.6, 0.1, 0.6]])
>>> mapped_samples = distribution.inv(mesh)
>>> mapped_samples.round(2)
array([[ 8.25,  8.67,  8.47,  8.88,  9.71, 10.13,  9.93, 10.35],
       [18.19, 18.19, 20.36, 20.36, 18.19, 18.19, 20.36, 20.36],
       [28.41, 29.88, 28.84, 30.31, 28.41, 29.88, 28.84, 30.31]])
>>> numpy.allclose(distribution.fwd(mapped_samples), mesh)
True
>>> distribution.pdf(mapped_samples).round(4)
array([0.0042, 0.0092, 0.0092, 0.0203, 0.0092, 0.0203, 0.0203, 0.0446])
>>> distribution.sample(4).round(4)
array([[10.3396,  9.0158, 11.1009, 10.0971],
       [21.6096, 18.871 , 17.5357, 19.6314],
       [29.6231, 30.7349, 28.7239, 30.5507]])
__init__(mu, sigma=None, rotation=None)[source]

Distribution initializer.

In addition to assigning some object variables, also checks for some consistency issues.

Args:
parameters (Optional[Distribution[str, Union[ndarray, Distribution]]]):

Collection of model parameters.

dependencies (Optional[Sequence[Set[int]]]):

Dependency identifiers. One collection for each dimension.

rotation (Optional[Sequence[int]]):

The order of which to resolve dependencies.

exclusion (Optional[Sequence[int]]):

Distributions that has been “taken out of play” and therefore can not be reused other places in the dependency hierarchy.

repr_args (Optional[Sequence[str]]):

Positional arguments to place in the object string representation. The repr output will then be: <class name>(<arg1>, <arg2>, …).

Raises:
StochasticallyDependentError:

For dependency structures that can not later be rectified. This include under-defined distributions, and inclusion of distributions that should be exclusion.

Methods

pdf(x_data[, decompose, allow_approx, step_size])

Probability density function.

cdf(x_data)

Cumulative distribution function.

fwd(x_data)

Forward Rosenblatt transformation.

inv(q_data[, max_iterations, tollerance])

Inverse Rosenblatt transformation.

sample([size, rule, antithetic, ...])

Create pseudo-random generated samples.

mom(K[, allow_approx])

Raw statistical moments.

ttr(kloc)

Three terms relation's coefficient generator.

Attributes

interpret_as_integer

Flag indicating that return value from the methods sample, and inv should be interpreted as integers instead of floating point.

lower

Lower bound for the distribution.

stochastic_dependent

True if distribution contains stochastically dependent components.

upper

Upper bound for the distribution.