Welcome to Random Events’ documentation!

Probabilistic Machine Learning frequently requires descriptions of random variables and events that are shared among many packages. This package provides a common interface for describing random variables and events, using usable and easily extensible classes.

Install the package via

pip install random-events

The formalism behind this package is the Product Measure.

Introduction

The package contains two modules.

Variables

The first one is Variables random_events.variables which contains the taxonomy and definitions of random variables. Random Variables are described by their name and by their domain. They are structured as follows

Inheritance diagram of random_events.variables

Variables are order-able and comparable by their name.

Variables split in two categories, random_events.variables.Discrete and random_events.variables.Continuous. Discrete variables are described by a (finite) set of possible values while continuous variables are defined on the real line.

Continuous Variables are described using portion intervals. This allows to describe intervals with infinite bounds and to perform operations on them, such as union, intersection, difference, etc.

Discrete Variables further split into integer variables and symbolic variables. While integer variables are described by finite sets of order-able elements, symbolic variables are described by a set of not order-able symbols.

The domains of discrete variables are stored as tuples and should not be modified after creation.

Events

While the literature describes events as arbitrary sets of outcomes, research has shown that there is a limited number of events that are tractable to calculate on. These are the sets that can be described by independent restrictions. For example, the event that \(0 < x < 1\) and \(y > 2\) can be calculated by some models, since the bounds for \(x\) and \(y\) are defined independently of each other. Unfortunately, it turned out that calculations on dependent integrals, such as \(0 < x < y\), are intractable for most (all) models. Further information on the reasons behind such limitations are found in literature on Probabilistic Circuits.

The package contains the module random_events.events for the taxonomy and definitions of random events. Random events are structured as follows

Inheritance diagram of random_events.events

Random events extend dictionary like functionality for easy access and modification. The most basic class is the random_events.events.VariableMap class, which is a dictionary that assigns variables to arbitrary values. This can be used for storing distributions, for example. The random_events.events.Event class extends the random_events.events.VariableMap class by only allowing the assignment of variables to values that are in the domain of the variable. These values are automatically converted to the correct type, if possible. An event is interpreted as a restriction on the full set of the variables involved. If, for example, \(\{ Dog, Cat \}\) is assigned to a variable about animals, it describes the event that the animal is either a dog or a cat.

Furthermore, intersections of events are possible. The intersection is done variable wise.

The next class is the random_events.events.EncodedEvent class, which converts events to representations that are usable for indexing. For discrete variables, the values are converted to indices, while for continuous variables, the values are not changed.

The last class is the random_events.events.ComplexEvent class. This class holds a list of disjoint events. It can be seen as the result of operations where the result is not a single event, but a set of events. Formally, it is the product outer measure.

Examples

Indices and tables