algebra
This module defines the commutative algebra structure of probability distributions.
We define an Algebra
class for enforcing the requisite structure via
abstract-method definitions for left-operators. Right-operators for
each left-operator is added on via setattr
on the Algebra class (see function
define_right_operators_for_Algebra_class
).
Algebra
An abstract class for enforcing the definition of operations we care about.
We specify left-operators as abstract methods in this class. Once
the class is defined, we define the right-operators as being the
swapped versions of their left-operators (see Algebra_reverse_op
for details on how this is achieved).
Note
This class is for internal use only.
Source code in distribution_algebra/algebra.py
__add__
abstractmethod
__mul__
abstractmethod
__neg__
abstractmethod
__pow__
abstractmethod
__sub__
abstractmethod
Algebra_reverse_op
Define the right-operator method, given a left-operator name in op_name
.
Note
This function is for internal use only.
Source code in distribution_algebra/algebra.py
define_right_operators_for_Algebra_class
Define a right-operator method for each of Algebra
's magic methods.
We additionally mark each right-operator as being final
in order
to guard against a user over-riding them and possibly breaking
symmetry with the left-operators.