pyuncertainnumber.pba.operation¶
Classes¶
Independent Vector of Pboxes |
|
Independent Matrix of Pboxes |
|
Vector of Pboxes |
Functions¶
|
Frechet operation on two pboxes |
|
The real naive Frechet bounds implementation |
|
this is a slow version |
|
perfect operation on two pboxes |
|
opposite operation on two pboxes |
|
independent operation on two pboxes |
|
Bivariate operation on two pboxes with a given copula |
|
Bivariate operation on two DSS with a given copula |
|
|
|
Compute the discrete copula mass matrix p_ij from grids u, v on [0,1]. |
|
positive dependence (PQD) convolution of two pboxes |
|
independent operation on two pboxes |
|
vectorised cartesian operation for the bounds of pboxes |
|
Sum of pboxes indepedently |
|
Convert any input un into a Pbox object |
|
backcal for p-boxes |
|
Additive deconvolution: returns b such that a + b ≈ c |
|
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:
- 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:
- 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:
- 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
sumwhich takes a list of inputsTip
Python
sumaccomplishes 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:
VectorIndependent Vector of Pboxes
- __add__(other)¶
- __matmul__(other)¶