Non-parametric p-boxes#

Functions that can be used to generate non-parametric p-boxes. These functions are used to generate p-boxes based upon the minimum, maximum, mean, median, mode, standard deviation, variance, and coefficient of variation of the variable.

pba.non_parametric.what_I_know(minimum: Interval | float | int | None = None, maximum: Interval | float | int | None = None, mean: Interval | float | int | None = None, median: Interval | float | int | None = None, mode: Interval | float | int | None = None, std: Interval | float | int | None = None, var: Interval | float | int | None = None, cv: Interval | float | int | None = None, percentiles: dict[Interval | float | int] | None = None, debug: bool = False, steps: int = 200) Pbox#

Generates a distribution free p-box based upon the information given. This function works by calculating every possible non-parametric p-box that can be generated using the information provided. The returned p-box is the intersection of these p-boxes.

Parameters:

minimum: Minimum value of the variable maximum: Maximum value of the variable mean: Mean value of the variable median: Median value of the variable mode: Mode value of the variable std: Standard deviation of the variable var: Variance of the variable cv: Coefficient of variation of the variable percentiles: Dictionary of percentiles and their values (e.g. {0.1: 1, 0.5: 2, 0.9: Interval(3,4)}) steps: Number of steps to use in the p-box

Error

ValueError: If any of the arguments are not consistent with each other. (i.e. if std and var are both given, but std != sqrt(var))

Returns:

Pbox: Imposition of possible p-boxes

pba.non_parametric.box(a: Interval | float | int, b: Interval | float | int | None = None, steps=200, shape='box') Pbox#

Returns a box shaped Pbox. This is equivalent to an Interval expressed as a Pbox.

Parameters:

a : Left side of box b: Right side of box

Returns:

Pbox

pba.non_parametric.min_max(a: Interval | float | int, b: Interval | float | int | None = None, steps=200, shape='box') Pbox#

Returns a box shaped Pbox. This is equivalent to an Interval expressed as a Pbox.

Parameters:

a : Left side of box b: Right side of box

Returns:

Pbox

pba.non_parametric.min_max_mean(minimum: Interval | float | int, maximum: Interval | float | int, mean: Interval | float | int, steps: int = 200) Pbox#

Generates a distribution-free p-box based upon the minimum, maximum and mean of the variable

Parameters:

minimum : minimum value of the variable

maximum : maximum value of the variable

mean : mean value of the variable

Returns:

Pbox

pba.non_parametric.min_max_mean_std(minimum: Interval | float | int, maximum: Interval | float | int, mean: Interval | float | int, std: Interval | float | int, steps: int = 200) Pbox#

Generates a distribution-free p-box based upon the minimum, maximum, mean and standard deviation of the variable

Parameters

minimum : minimum value of the variable maximum : maximum value of the variable mean : mean value of the variable std :standard deviation of the variable

Returns

Pbox

pba.non_parametric.min_max_mean_var(minimum: Interval | float | int, maximum: Interval | float | int, mean: Interval | float | int, var: Interval | float | int, steps: int = 200) Pbox#

Generates a distribution-free p-box based upon the minimum, maximum, mean and standard deviation of the variable

Parameters

minimum : minimum value of the variable maximum : maximum value of the variable mean : mean value of the variable var :variance of the variable

Returns

Pbox

Implementation

Equivalent to min_max_mean_std(minimum,maximum,mean,np.sqrt(var))

pba.non_parametric.min_max_mode(minimum: Interval | float | int, maximum: Interval | float | int, mode: Interval | float | int, steps: int = 200) Pbox#

Generates a distribution-free p-box based upon the minimum, maximum, and mode of the variable

Parameters:

minimum : minimum value of the variable

maximum : maximum value of the variable

mode : mode value of the variable

Returns:

Pbox

pba.non_parametric.min_max_median(minimum: Interval | float | int, maximum: Interval | float | int, median: Interval | float | int, steps: int = 200) Pbox#

Generates a distribution-free p-box based upon the minimum, maximum and median of the variable

Parameters:

minimum : minimum value of the variable

maximum : maximum value of the variable

median : median value of the variable

Returns:

Pbox

pba.non_parametric.min_max_median_is_mode(minimum: Interval | float | int, maximum: Interval | float | int, m: Interval | float | int, steps: int = 200) Pbox#

Generates a distribution-free p-box based upon the minimum, maximum and median/mode of the variable when median = mode.

Parameters:

minimum : minimum value of the variable

maximum : maximum value of the variable

m : m = median = mode value of the variable

Returns:

Pbox

pba.non_parametric.mean_std(mean: Interval | float | int, std: Interval | float | int, steps=200) Pbox#

Generates a distribution-free p-box based upon the mean and standard deviation of the variable

Parameters:

mean : mean of the variable

std : standard deviation of the variable

Returns:

Pbox

pba.non_parametric.mean_var(mean: Interval | float | int, var: Interval | float | int, steps=200) Pbox#

Generates a distribution-free p-box based upon the mean and variance of the variable

Equivalent to mean_std(mean,np.sqrt(var))

Parameters:

mean : mean of the variable

var : variance of the variable

Returns:

Pbox

pba.non_parametric.pos_mean_std(mean: Interval | float | int, std: Interval | float | int, steps=200) Pbox#

Generates a positive distribution-free p-box based upon the mean and standard deviation of the variable

Parameters:

mean : mean of the variable

std : standard deviation of the variable

Returns:

Pbox

pba.non_parametric.symmetric_mean_std(mean: Interval | float | int, std: Interval | float | int, steps: int = 200) Pbox#

Generates a symmetrix distribution-free p-box based upon the mean and standard deviation of the variable

Parameters:

mean : mean value of the variable std : standard deviation of the variable

Returns

Pbox

pba.non_parametric.from_percentiles(percentiles: dict, steps: int = 200) Pbox#

Generates a distribution-free p-box based upon percentiles of the variable

Parameters

percentiles : dictionary of percentiles and their values (e.g. {0: 0, 0.1: 1, 0.5: 2, 0.9: Interval(3,4), 1:5})

steps : number of steps to use in the p-box

Important

The percentiles dictionary is of the form {percentile: value}. Where value can either be a number or an Interval. If value is a number, the percentile is assumed to be a point percentile. If value is an Interval, the percentile is assumed to be an interval percentile.

Warning

If no keys for 0 and 1 are given, -np.inf and np.inf are used respectively. This will result in a p-box that is not bounded and raise a warning.

If the percentiles are not increasing, the percentiles will be intersected. This may not be desired behaviour.

Error

ValueError: If any of the percentiles are not between 0 and 1.

Returns

Pbox

Example:

pba.from_percentiles(
    {0: 0,
    0.25: 0.5,
    0.5: pba.I(1,2),
    0.75: pba.I(1.5,2.5),
    1: 3}
).show()
Pbox generated from percentiles