Credal Sets

class murasyp.credalsets.CredalSet(data=[])[source]

A set of probability mass functions

type data:a non-Mapping Iterable Container of arguments accepted by the PMFunc constructor.
>>> assert (
...     CredalSet('abc') ==
...     CredalSet({PMFunc({'a': 1}), PMFunc({'b': 1}), PMFunc({'c': 1})})
... )

This class derives from set, so its methods apply here as well.

Todo

test all set methods and fix, or elegantly deal with, broken ones

Additional and changed methods:

  • Lower and upper (conditional) expectations can be calculated, using the * and ** operators, respectively.

    >>> p = PMFunc({'a': .03, 'b': .07, 'c': .9})
    >>> q = PMFunc({'a': .07, 'b': .03, 'c': .9})
    >>> K = CredalSet([p, q])
    >>> f = Gamble({'a': -1, 'b': 1, 'c': 0})
    >>> K * f
    Fraction(-1, 25)
    >>> K ** f
    Fraction(1, 25)
    >>> K * (f | f.support())
    Fraction(-2, 5)
    >>> K ** (f | f.support())
    Fraction(2, 5)
    

    Note

    The domain of the gamble determines the conditioning event.

  • They can be conditioned (each element PMFunc is).

    >>> p = PMFunc({'a': .03, 'b': .07, 'c': .9})
    >>> q = PMFunc({'a': .07, 'b': .03, 'c': .9})
    >>> K = CredalSet([p, q])
    >>> f = Gamble({'a': -1, 'b': 1})
    >>> A = {'a','b'}
    >>> (K | A) * f
    Fraction(-2, 5)
    >>> (K | A) ** f
    Fraction(2, 5)
    

    This does not impede the classical union of sets.

    >>> assert (
    ...     CredalSet('a') | CredalSet('b') ==
    ...     CredalSet({PMFunc({'a': 1}), PMFunc({'b': 1})})
    ... )
    
add(data)[source]

Add a probability mass function to the credal set

type data:arguments accepted by the PMFunc constructor
>>> K = CredalSet()
>>> assert K == CredalSet()
>>> K.add({'a': .06, 'b': .14, 'c': 1.8, 'd': 0})
>>> assert (
...     K ==
...     CredalSet({PMFunc({'a': '3/100', 'c': '9/10', 'b': '7/100'})})
... )

Todo

see whether all set functionality is carried over

discard(data)[source]

Remove a probability mass function from the credal set

type data:arguments accepted by the PMFunc constructor
>>> K = CredalSet('ab')
>>> assert K == CredalSet({PMFunc({'a': 1}), PMFunc({'b': 1})})
>>> K.discard(PMFunc({'a'}))
>>> assert K == CredalSet({PMFunc({'b': 1})})

Todo

see whether all set functionality is carried over

pspace()[source]

The possibility space of the credal set

returns:the possibility space of the credal set, i.e., the union of the domains of the probability mass functions it contains
rtype:frozenset
>>> p = PMFunc({'a': .03, 'b': .07})
>>> q = PMFunc({'a': .07, 'c': .03})
>>> K = CredalSet([p, q])
>>> assert K.pspace() == frozenset({'a', 'c', 'b'})
discard_redundant()[source]

Remove redundant elements from the credal set

Redundant elements are those that are not vertices of the credal set’s convex hull.

>>> K = CredalSet('abc')
>>> K.add({'a': 1, 'b': 1, 'c': 1})
>>> assert (
...     K ==
...     CredalSet(
...         {PMFunc({'a': '1/3', 'c': '1/3', 'b': '1/3'}),
...          PMFunc({'a': 1}), PMFunc({'b': 1}), PMFunc({'c': 1})}
...     )
... )
>>> K.discard_redundant()
>>> assert (
...     K ==
...     CredalSet(
...         {PMFunc({'a': 1}), PMFunc({'b': 1}), PMFunc({'c': 1})})
... )
get_desir()[source]

Generate the corresponding open set of desirable gambles

returns:the set of desirable gambles that corresponds as an uncertainty model
rtype:DesirSet
>>> assert (
...     CredalSet([PMFunc({'a', 'b'}), PMFunc({'c', 'b'}),
...                PMFunc({'a'}), PMFunc({'c'})]).get_desir() ==
...     DesirSet({Cone({Ray({'a': 1}), Ray({'b': 1}), Ray({'c': 1}),
...                     Ray({'a': 1, 'c': 1, 'b': -1})})})
... )

Previous topic

Mass Functions

Next topic

Mathematical programming & polytope theory

This Page