Probability Boxes#
- class pba.pbox.Pbox#
A probability distribution is a mathematical function that gives the probabilities of occurrence for different possible values of a variable. Probability boxes (p-boxes) represent interval bounds on probability distributions. The simplest kind of p-box can be expressed mathematically as
\[\mathcal{F}(x) = [\underline{F}(x),\overline{F}(x)], \ \underline{F}(x)\geq \overline{F}(x)\ \forall x \in \mathbb{R}\]where \(\underline{F}(x)\) is the function that defines the left bound of the p-box and \(\overline{F}(x)\) defines the right bound of the p-box. In PBA the left and right bounds are each stored as a NumPy array containing the percent point function (the inverse of the cumulative distribution function) for steps evenly spaced values between 0 and 1. P-boxes can be defined using all the probability distributions that are available through SciPy’s statistics library,
Naturally, precise probability distributions can be defined in PBA by defining a p-box with precise inputs. This means that within probability bounds analysis probability distributions are considered a special case of a p-box with zero width. Resultantly, all methodology that applies to p-boxes can also be applied to probability distributions.
Distribution-free p-boxes can also be generated when the underlying distribution is unknown but parameters such as the mean, variance or minimum/maximum bounds are known. Such p-boxes make no assumption about the shape of the distribution and instead return bounds expressing all possible distributions that are valid given the known information. Such p-boxes can be constructed making use of Chebyshev, Markov and Cantelli inequalities from probability theory.
Attention
It is usually better to define p-boxes using distributions or non-parametric methods (see ). This constructor is provided for completeness and for the construction of p-boxes with precise inputs.
- Parameters:
left – Left bound of the p-box. Can be a list, NumPy array, Interval or numeric type. If left is None, the left bound is set to -inf.
- __init__(left=None, right=None, steps=None, shape=None, mean_left=None, mean_right=None, var_left=None, var_right=None, interpolation='linear')#
Attention
It is usually better to define p-boxes using distributions or non-parametric methods (see ). This constructor is provided for completeness and for the construction of p-boxes with precise inputs.
- Parameters:
left – Left bound of the p-box. Can be a list, NumPy array, Interval or numeric type. If left is None, the left bound is set to -inf.
- add(other: Pbox | Interval | float | int, method='f') Pbox #
Adds to Pbox to other using the defined dependency method
- env(other)#
Computes the envelope of two Pboxes.
Parameters: - other: Pbox or numeric value
The other Pbox or numeric value to compute the envelope with.
Returns: - Pbox
The envelope Pbox.
Raises: - ArithmeticError: If both Pboxes have different number of steps.
- get_x()#
returns the x values for plotting
- get_y()#
returns the y values for plotting
- hi()#
Returns the right-most value in the interval
- imp(other)#
Returns the imposition of self with other
- lo()#
Returns the left-most value in the interval
- min(other, method='f')#
Returns a new Pbox object that represents the element-wise minimum of two Pboxes.
- Parameters:
other: Another Pbox object or a numeric value.
method: Calculation method to determine the minimum. Can be one of ‘f’, ‘p’, ‘o’, ‘i’.
- Returns:
Pbox
- pow(other: Pbox | Interval | float | int, method='f') Pbox #
Raises a p-box to the power of other using the defined dependency method
- Parameters:
other – Pbox, Interval or numeric type
method –
- Returns:
Pbox
- Return type:
- straddles(N, endpoints=True) bool #
Parameters#
- Nnumeric
Number to check
- endpointsbool
Whether to include the endpoints within the check
Returns#
- True
If \(\mathrm{left} \leq N \leq \mathrm{right}\) (Assuming endpoints=True)
- False
Otherwise
- straddles_zero(endpoints=True) bool #
Checks whether \(0\) is within the p-box
- truncate(a, b, method='f')#
Equivalent to self.min(a,method).max(b,method)