chaospy.Binomial

class chaospy.Binomial(size, prob)[source]

Binomial probability distribution.

Point density:

comb(N, x) p^x (1-p)^{N-x} x in {0, 1, …, N}

Examples:
>>> distribution = chaospy.Binomial(3, 0.5)
>>> distribution
Binomial(3, 0.5)
>>> xloc = numpy.arange(4)
>>> distribution.pdf(xloc).round(4)
array([0.125, 0.375, 0.375, 0.125])
>>> distribution.cdf(xloc).round(4)
array([0.125, 0.5  , 0.875, 1.   ])
>>> distribution.fwd([-0.5, -0.49, 0, 0.49, 0.5]).round(4)
array([0.    , 0.0013, 0.0625, 0.1238, 0.125 ])
>>> uloc = numpy.linspace(0, 1, 8)
>>> uloc.round(2)
array([0.  , 0.14, 0.29, 0.43, 0.57, 0.71, 0.86, 1.  ])
>>> distribution.inv(uloc).round(2)
array([-0.5 ,  0.55,  0.93,  1.31,  1.69,  2.07,  2.45,  3.5 ])
>>> distribution.sample(10)
array([1, 3, 2, 1, 0, 1, 1, 0, 2, 1])
>>> distribution.mom([1, 2, 3]).round(4)
array([1.5 , 3.  , 6.75])
__init__(size, prob)[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.