chaospy.Iid

class chaospy.Iid(dist, length, rotation=None)[source]

Opaque method for creating independent identical distributed random variables from an univariate variable.

Args:
dist (Distribution):

Distribution to make into i.i.d. vector. The distribution will be copied so to not become a part of the dependency graph.

length (int):

The length of new distribution.

Examples:
>>> distribution = chaospy.Iid(chaospy.Normal(0, 1), 2)
>>> distribution
Iid(Normal(mu=0, sigma=1), 2)
>>> chaospy.Cov(distribution)
array([[1., 0.],
       [0., 1.]])
>>> mesh = numpy.mgrid[0.25:0.75:3j, 0.25:0.75:3j].reshape(2, -1)
>>> mapped_mesh = distribution.inv(mesh)
>>> mapped_mesh.round(2)
array([[-0.67, -0.67, -0.67,  0.  ,  0.  ,  0.  ,  0.67,  0.67,  0.67],
       [-0.67,  0.  ,  0.67, -0.67,  0.  ,  0.67, -0.67,  0.  ,  0.67]])
>>> distribution.fwd(mapped_mesh).round(2)
array([[0.25, 0.25, 0.25, 0.5 , 0.5 , 0.5 , 0.75, 0.75, 0.75],
       [0.25, 0.5 , 0.75, 0.25, 0.5 , 0.75, 0.25, 0.5 , 0.75]])
>>> distribution.pdf(mapped_mesh).round(3)
array([0.101, 0.127, 0.101, 0.127, 0.159, 0.127, 0.101, 0.127, 0.101])
>>> distribution.sample(4, rule="halton").round(3)
array([[-1.15 ,  0.319, -0.319,  1.15 ],
       [-0.14 ,  0.765, -0.765,  0.14 ]])
>>> distribution.mom([[1, 2, 2], [2, 1, 2]]).round(12)
array([0., 0., 1.])
__init__(dist, length, 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.