chaospy.UserDistribution

class chaospy.UserDistribution(cdf, pdf=None, lower=None, upper=None, ppf=None, mom=None, ttr=None, parameters=None)[source]

Distribution with user-provided methods.

The internals of this distribution is provided in the constructor.

Examples:
>>> def cdf(x_loc, lo, up):
...     '''Cumulative distribution function.'''
...     return (x_loc-lo)/(up-lo)
>>> def pdf(x_loc, lo, up):
...     '''Probability density function.'''
...     return 1./(up-lo)
>>> def lower(lo, up):
...     '''Lower bounds function.'''
...     return lo
>>> def upper(lo, up):
...     '''Upper bounds function.'''
...     return up
>>> distribution = chaospy.UserDistribution(
...     cdf, pdf, lower, upper, parameters=dict(lo=-1, up=1))
>>> distribution
UserDistribution(<function ..., parameters=dict(lo=-1, up=1))
>>> distribution.fwd(numpy.linspace(-2, 2, 7)).round(4)
array([0.    , 0.    , 0.1667, 0.5   , 0.8333, 1.    , 1.    ])
>>> distribution.pdf(numpy.linspace(-2, 2, 7)).round(4)
array([0. , 0. , 0.5, 0.5, 0.5, 0. , 0. ])
>>> distribution.inv(numpy.linspace(0, 1, 7)).round(4)
array([-1.    , -0.6667, -0.3333,  0.    ,  0.3333,  0.6667,  1.    ])
>>> distribution.lower, distribution.upper
(array([-1.]), array([1.]))
__init__(cdf, pdf=None, lower=None, upper=None, ppf=None, mom=None, ttr=None, parameters=None)[source]
Args:
cdf (Callable[[numpy.ndarray, …], numpy.ndarray]):

Cumulative distribution function.

pdf (Callable[[numpy.ndarray, …], numpy.ndarray]):

Probability density function.

lower (Callable[[…], numpy.ndarray]):

Lower boundary.

upper (Callable[[…], numpy.ndarray]):

Upper boundary.

ppf (Callable[[numpy.ndarray, …], numpy.ndarray]):

Point percentile function.

mom (Callable[[numpy.ndarray, …], numpy.ndarray]):

Raw moment generator.

ttr (Callable[[numpy.ndarray, …], numpy.ndarray]):

Three terms recurrence coefficient generator.

parameters (Dict[str, numpy.ndarray]):

Parameters to pass to each of the distribution methods.

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.