chaospy.TruncNormal

class chaospy.TruncNormal(lower=- inf, upper=inf, mu=0, sigma=1)[source]

Truncated normal distribution

Args:
lower (float, Distribution):

Location of lower threshold

upper (float, Distribution):

Location of upper threshold

mu (float, Distribution):

Mean of normal distribution

sigma (float, Distribution):

Standard deviation of normal distribution

Examples:
>>> full_trunc = chaospy.TruncNormal(lower=-1, upper=1)
>>> half_trunc = chaospy.TruncNormal(upper=1)
>>> uloc = numpy.linspace(0, 1, 6)
>>> uloc
array([0. , 0.2, 0.4, 0.6, 0.8, 1. ])
>>> half_trunc.inv(uloc).round(3)
array([-8.22 , -0.961, -0.422,  0.012,  0.448,  1.   ])
>>> xloc = full_trunc.inv(uloc)
>>> xloc.round(3)
array([-1.   , -0.538, -0.172,  0.172,  0.538,  1.   ])
>>> numpy.allclose(full_trunc.fwd(xloc), uloc)
True
>>> full_trunc.pdf(xloc).round(3)
array([0.354, 0.506, 0.576, 0.576, 0.506, 0.354])
>>> half_trunc.pdf(xloc).round(3)
array([0.288, 0.41 , 0.467, 0.467, 0.41 , 0.288])
>>> full_trunc.sample(4).round(3)
array([ 0.266, -0.715,  0.868, -0.03 ])
>>> half_trunc.sample(4).round(3)
array([ 0.625, -0.921, -1.822, -0.428])
>>> full_trunc.mom([1, 2, 3]).round(8)
array([0.        , 0.29112509, 0.        ])
>>> half_trunc.mom([1, 2, 3]).round(8)
array([-0.28759997,  0.71240003, -0.86279991])
__init__(lower=- inf, upper=inf, mu=0, sigma=1)[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.