pyuncertainnumber.pba.operation =============================== .. py:module:: pyuncertainnumber.pba.operation Classes ------- .. autoapisummary:: pyuncertainnumber.pba.operation.Vector pyuncertainnumber.pba.operation.Matrix pyuncertainnumber.pba.operation.iVector pyuncertainnumber.pba.operation.iMatrix pyuncertainnumber.pba.operation.Vector_pbox Functions --------- .. autoapisummary:: pyuncertainnumber.pba.operation.frechet_op pyuncertainnumber.pba.operation.naive_frechet_op pyuncertainnumber.pba.operation.new_naive_frechet_op pyuncertainnumber.pba.operation.perfect_op pyuncertainnumber.pba.operation.opposite_op pyuncertainnumber.pba.operation.independent_op pyuncertainnumber.pba.operation.copula_op pyuncertainnumber.pba.operation.copula_dss_op pyuncertainnumber.pba.operation.C_func pyuncertainnumber.pba.operation.copula_mass pyuncertainnumber.pba.operation.positiveconv_pbox pyuncertainnumber.pba.operation.new_vectorised_naive_frechet_op pyuncertainnumber.pba.operation.vectorized_cartesian_op pyuncertainnumber.pba.operation.isum pyuncertainnumber.pba.operation.convert pyuncertainnumber.pba.operation.p_backcalc pyuncertainnumber.pba.operation.adec pyuncertainnumber.pba.operation.i_mul Module Contents --------------- .. py:function:: 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 .. py:function:: 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` :param x: pboxes to be operated on :type x: Pbox :param y: pboxes to be operated on :type y: Pbox :param op: arithemtic operator to be applied, e.g. operator.add :type op: function :returns: left and right bounds of the pbox - Zu: lower bound of the pbox - Zd: upper bound of the pbox :rtype: Zu, Zd (tuple) .. rubric:: 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) .. py:function:: 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 .. py:function:: 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. .. py:function:: 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. .. py:function:: 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. .. py:function:: 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 :rtype: Pbox .. py:function:: 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 :rtype: Pbox .. py:function:: C_func(u, v, copula) .. py:function:: 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 .. py:function:: positiveconv_pbox(a, b, op=operator.add) positive dependence (PQD) convolution of two pboxes .. rubric:: Example >>> X = pba.uniform(1, 24) >>> Y = X >>> p_ = positiveconv_pbox(X, Y) .. py:function:: 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. .. py:function:: vectorized_cartesian_op(a, b, op) vectorised cartesian operation for the bounds of pboxes .. note:: used on self.left, other.left .. rubric:: Example >>> nleft = vectorized_cartesian_op(self.left, other.left, operator.add) >>> nright = vectorized_cartesian_op(self.right, other.right, operator.add) .. py:function:: isum(l_p) Sum of pboxes indepedently :param l_p: list of Pbox objects :type l_p: list .. note:: Same signature with Python ``sum`` which takes a list of inputs .. tip:: Python ``sum`` accomplishes sum of Frechet case. .. py:function:: convert(un) Convert any input un into a Pbox object .. note:: - theorically 'un' can be {Interval, DempsterShafer, Distribution, float, int} .. py:function:: 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 .. py:function:: adec(a, c) Additive deconvolution: returns b such that a + b ≈ c Assumes a, b, c are instances of RandomNbr. .. note:: implmentation from Scott .. py:function:: i_mul(a, b) bivariate independent multiplication of pboxes .. py:class:: Vector(components) .. py:attribute:: components .. py:method:: __iter__() .. py:method:: __len__() .. py:method:: __repr__() .. py:method:: __getitem__(index) .. py:method:: __setitem__(index, value) .. py:method:: __add__(other) .. py:method:: __sub__(other) .. py:method:: __mul__(other) .. py:method:: __rmul__(other) .. py:method:: __truediv__(other) .. py:method:: __matmul__(other) .. py:method:: tanh() Pbox tanh operation elemenwise .. py:class:: Matrix(rows) .. py:method:: __getitem__(index) .. py:method:: __len__() .. py:method:: shape() .. py:method:: __repr__() .. py:method:: __setitem__(index, value) .. py:method:: __add__(other) .. py:method:: __sub__(other) .. py:method:: __mul__(other) .. py:method:: __rmul__(other) .. py:method:: __truediv__(other) .. py:method:: __matmul__(other) .. py:method:: tanh() .. py:class:: iVector(components) Bases: :py:obj:`Vector` Independent Vector of Pboxes .. py:method:: __add__(other) .. py:method:: __matmul__(other) .. py:class:: iMatrix(rows) Bases: :py:obj:`Matrix` Independent Matrix of Pboxes .. py:method:: __add__(other) .. py:method:: __matmul__(other) .. py:class:: Vector_pbox(components) Bases: :py:obj:`Vector` Vector of Pboxes .. py:method:: __matmul__(other)