pyuncertainnumber.pba.operation

Classes

Vector

Matrix

iVector

Independent Vector of Pboxes

iMatrix

Independent Matrix of Pboxes

Vector_pbox

Vector of Pboxes

Functions

frechet_op(x, y[, op])

Frechet operation on two pboxes

naive_frechet_op(x, y, op)

The real naive Frechet bounds implementation

new_naive_frechet_op(x, y, op[, n_sam])

this is a slow version

perfect_op(x, y[, op])

perfect operation on two pboxes

opposite_op(x, y[, op])

opposite operation on two pboxes

independent_op(x, y[, op])

independent operation on two pboxes

copula_op(→ pyuncertainnumber.pba.pbox_abc.Pbox)

Bivariate operation on two pboxes with a given copula

copula_dss_op(→ pyuncertainnumber.pba.pbox_abc.Pbox)

Bivariate operation on two DSS with a given copula

C_func(u, v, copula)

copula_mass(C_func, u, v[, eps])

Compute the discrete copula mass matrix p_ij from grids u, v on [0,1].

positiveconv_pbox(a, b[, op])

positive dependence (PQD) convolution of two pboxes

new_vectorised_naive_frechet_op(x, y, op)

independent operation on two pboxes

vectorized_cartesian_op(a, b, op)

vectorised cartesian operation for the bounds of pboxes

isum(l_p)

Sum of pboxes indepedently

convert(un)

Convert any input un into a Pbox object

p_backcalc(a, c, ops)

backcal for p-boxes

adec(a, c)

Additive deconvolution: returns b such that a + b ≈ c

i_mul(a, b)

bivariate independent multiplication of pboxes

Module Contents

pyuncertainnumber.pba.operation.frechet_op(x: pyuncertainnumber.pba.pbox_abc.Pbox, y: pyuncertainnumber.pba.pbox_abc.Pbox, op=operator.add)

Frechet operation on two pboxes

Note

this corresponds to the Frank, Nelson and Sklar Frechet bounds implementation

pyuncertainnumber.pba.operation.naive_frechet_op(x: pyuncertainnumber.pba.pbox_abc.Pbox, y: pyuncertainnumber.pba.pbox_abc.Pbox, op)

The real naive Frechet bounds implementation

Note

counterpart of naivefrechetpbox in pba.r

Parameters:
  • x (Pbox) – pboxes to be operated on

  • y (Pbox) – pboxes to be operated on

  • op (function) – arithemtic operator to be applied, e.g. operator.add

Returns:

left and right bounds of the pbox - Zu: lower bound of the pbox - Zd: upper bound of the pbox

Return type:

Zu, Zd (tuple)

Example

>>> from pyuncertainnumber import pba
>>> a = pba.normal([4,5], 1)
>>> b = pba.uniform([3,4], [7,8])
>>> left_bound, right_bound = pba.naive_frechet_op(a, b, operator.add)
pyuncertainnumber.pba.operation.new_naive_frechet_op(x: pyuncertainnumber.pba.pbox_abc.Pbox, y: pyuncertainnumber.pba.pbox_abc.Pbox, op, n_sam=Params.steps)

this is a slow version

pyuncertainnumber.pba.operation.perfect_op(x: pyuncertainnumber.pba.pbox_abc.Pbox, y: pyuncertainnumber.pba.pbox_abc.Pbox, op=operator.add)

perfect operation on two pboxes

Note

defined for addition and multiplication. Different for subtraction and division.

pyuncertainnumber.pba.operation.opposite_op(x: pyuncertainnumber.pba.pbox_abc.Pbox, y: pyuncertainnumber.pba.pbox_abc.Pbox, op=operator.add)

opposite operation on two pboxes

Note

defined for addition and multiplication. Different for subtraction and division.

pyuncertainnumber.pba.operation.independent_op(x: pyuncertainnumber.pba.pbox_abc.Pbox, y: pyuncertainnumber.pba.pbox_abc.Pbox, op=operator.add)

independent operation on two pboxes

Note

defined for addition and multiplication. Different for subtraction and division.

pyuncertainnumber.pba.operation.copula_op(x: pyuncertainnumber.pba.pbox_abc.Pbox, y: pyuncertainnumber.pba.pbox_abc.Pbox, dependency: pyuncertainnumber.pba.dependency.Dependency, op=operator.add) pyuncertainnumber.pba.pbox_abc.Pbox

Bivariate operation on two pboxes with a given copula

Returns:

resulting pbox after applying the operation with the copula

Return type:

Pbox

pyuncertainnumber.pba.operation.copula_dss_op(x: pyuncertainnumber.pba.dss.DempsterShafer, y: pyuncertainnumber.pba.dss.DempsterShafer, dependency, op=operator.add) pyuncertainnumber.pba.pbox_abc.Pbox

Bivariate operation on two DSS with a given copula

Note

This is a temporary function until DSS is fully integrated with Pbox operations

Returns:

resulting DSS after applying the operation with the copula

Return type:

Pbox

pyuncertainnumber.pba.operation.C_func(u, v, copula)
pyuncertainnumber.pba.operation.copula_mass(C_func, u, v, eps=1e-12)

Compute the discrete copula mass matrix p_ij from grids u, v on [0,1]. C: callable taking arrays (same shape) and returning C(u,v) u, v: 1D arrays (ascending) of points in [0,1] eps: small value to avoid ±inf when calling C near 0 or 1

pyuncertainnumber.pba.operation.positiveconv_pbox(a, b, op=operator.add)

positive dependence (PQD) convolution of two pboxes

Example

>>> X = pba.uniform(1, 24)
>>> Y = X
>>> p_ = positiveconv_pbox(X, Y)
pyuncertainnumber.pba.operation.new_vectorised_naive_frechet_op(x: pyuncertainnumber.pba.pbox_abc.Pbox, y: pyuncertainnumber.pba.pbox_abc.Pbox, op)

independent operation on two pboxes

Note

defined for addition and multiplication. Different for subtraction and division.

pyuncertainnumber.pba.operation.vectorized_cartesian_op(a, b, op)

vectorised cartesian operation for the bounds of pboxes

Note

used on self.left, other.left

Example

>>> nleft = vectorized_cartesian_op(self.left, other.left, operator.add)
>>> nright = vectorized_cartesian_op(self.right, other.right, operator.add)
pyuncertainnumber.pba.operation.isum(l_p)

Sum of pboxes indepedently

Parameters:

l_p (list) – list of Pbox objects

Note

Same signature with Python sum which takes a list of inputs

Tip

Python sum accomplishes sum of Frechet case.

pyuncertainnumber.pba.operation.convert(un)

Convert any input un into a Pbox object

Note

  • theorically ‘un’ can be {Interval, DempsterShafer, Distribution, float, int}

pyuncertainnumber.pba.operation.p_backcalc(a, c, ops)

backcal for p-boxes #! incorrect implementation :param a: probability box objects :type a: Pbox :param c: probability box objects :type c: Pbox :param ops: {‘additive_bcc’, ‘multiplicative_bcc’} whether additive or multiplicative :type ops: object

pyuncertainnumber.pba.operation.adec(a, c)

Additive deconvolution: returns b such that a + b ≈ c Assumes a, b, c are instances of RandomNbr.

Note

implmentation from Scott

pyuncertainnumber.pba.operation.i_mul(a, b)

bivariate independent multiplication of pboxes

class pyuncertainnumber.pba.operation.Vector(components)
components
__iter__()
__len__()
__repr__()
__getitem__(index)
__setitem__(index, value)
__add__(other)
__sub__(other)
__mul__(other)
__rmul__(other)
__truediv__(other)
__matmul__(other)
tanh()

Pbox tanh operation elemenwise

class pyuncertainnumber.pba.operation.Matrix(rows)
__getitem__(index)
__len__()
shape()
__repr__()
__setitem__(index, value)
__add__(other)
__sub__(other)
__mul__(other)
__rmul__(other)
__truediv__(other)
__matmul__(other)
tanh()
class pyuncertainnumber.pba.operation.iVector(components)

Bases: Vector

Independent Vector of Pboxes

__add__(other)
__matmul__(other)
class pyuncertainnumber.pba.operation.iMatrix(rows)

Bases: Matrix

Independent Matrix of Pboxes

__add__(other)
__matmul__(other)
class pyuncertainnumber.pba.operation.Vector_pbox(components)

Bases: Vector

Vector of Pboxes

__matmul__(other)