“We were somewhere around Barstow, on the edge of the desert, when the drugs began to take hold.”

― Hunter S. Thompson, Fear and Loathing in Las Vegas

This post is the third in a three part series

In part II I discussed how probability theory deserves its own category, the same way that other sub fields of mathematics have their own category. I showed how the standard definition does not transform properly under restriction, and prohibits the the formation of a category. This motivated us to consider an alternative definition. However, I never illustrated the category which results. The present post accomplishes one thing: we will make a category for probability theory and tie it to the classical foundations.

## The category of measurable spaces

A measurable space consists of a pair, , where is a set and is a -algebra. We think of the elements of as events when we talk about probability. Informally, a -algebra is just the algebraic entity which encodes the notion of a space of events. For the formal definition see the wikipedia link. Given two -algebras, and , we say that is measurable if for every . The collection of all measurable spaces forms a category where the arrows are given by measurable maps.

## The category of measure cones

A measure on a measurable space, , is just a map such that

where denotes disjoint union. We denote the space of measures over a by and we will call such a space a measure-space.

Note that given two measures we can sum them to get a measure so that forms a convex cone.

The assignment “” is actually a functor, but to clarify that I need to describe the arrows.

## Arrows between measure cones

Not that for each event , we can describe a new -algebra where . In fact this characterizes all the sub-algebras of . So we see each -algebra is equipped with a set of inclusion maps from it’s sub-algebras.

The inclusion map can be lifted to a map which embeds .
It’s a measureable map after all.
A **posterior measure** is a map, such that for any
there exists a unique map which makes the diagram

commute. *Sidetrack: Something here is eerily reminiscent of a pre-sheaf.*

The correspondence with the classical notion of a posterior measure might not be obvious. In the case where is a manifold, a classical posterior measure, where and induces a map which sends a measure to a measures by . In the discrete case, the integral just becomes a sum. This mapping satisfies the commutative diagram, so we at least see the classical posteriors as special cases, and so have illustrated one direction of this equivalence.

The other direction can be demonstrated as well. This mapping from to completely characterizes the posterior . This is most easily illustrated in the case where is finite. Then you can take to be a singleton set, for some , in which case is just a scalar which we’ll call . The measure has support on a single point, namely , and the comutativity of the diagram implies that for any that for some measure . However, all measures in are direct sums of measures of the form where is the immersion of a singleton set. Therefore, for a generic we have . The measure is just a manifestation of what is classically written as “”. In the case where is a continuous algebra, the summation just becomes integration. For generic -algebras, I’m not sure how to write things, but in that scenario the top-down categorical definition of a posterior might serve us better anyway, by foregoing the need to write down an explicit expression.

Having defined posterior measures in this way, we see that the posterior measures are good candidates for the arrows of the category of measures. We need only define the composition operation.

## The composition

The composition operation is (perhaps unsurprisingly) the chain rule of measure theory. Given posteriors , and a posterior , we can compose them to get the posterior . If we write this composition down using classical notation we find .

Having defined a collection of objects, the measure cones , and arrows, represented by posteriors, we see that we have a category, which I’ll dub .

## Somebody has been here

Definitely trodden territory. This notion of using posteriors as arrows is discussed at the n-category cafe and at the n-lab where they talk about a theory of “Probabilistic Relations”, by Prakash Panangaden. Apparently this line of thought goes back all the way to the early days of category theory, to an unpublished manuscript Lawvere wrote in the 1962 called “The category of probabilistic mappings”. This manuscript was later elaborated on by M. Giry in “a categorical approach to probability theory” where the functor serves as the key ingredient to Monad. He then forms the Kleisli category of this monad, which apparently provides some insight into Chapman-Kolmogorov relations. This paper by Giry looks like a lot of fun, but to be honest, as a hobbyist mathematician with a fairly intense (less mathy) day job, I probably wont find the time to give Giry’s work the attention it deserves any time soon.

## Our first functor

We are ready for our first functor, which sends the category of -algebras to . This is the functor given by “” in Giry’s paper. For each there is a measure cone , and for each measureable map there is a posterior measure given by , basically sending a measure to its push-forward. Note, this functor does not give all posteriors. The only posteriors of this form have very Dirac-delta feel to them.

## From measures to probabilities

Getting from measures to probabilities is fairly trivial now. We just apply the ray functor (see part I of the series). We’ve already established that is a cone. Therefore, the notion of a ray is sensible, and we can send each non-zero measure to a ray where denotes the ray-space of . These rays are (very modest generalization of) probability densities on . This was the content of the last few posts.

I’d like to promote the assignment of “”” to a functor. To do so, I must figure out how should handle the arrows in the category of measure cones, the posterior measures. The set of posterior measures between and is itself a convex cone. So again, the notion of a ray is well defined there. The ray of a posterior measure is just what it sounds like, and applying to the posterior measures in this way gives us a functor to a new category, which we will call .

## The category of probability theory

In , the objects are the spaces which consist of the ray space of . The rays themselves correspond with probability densities (see the first post). The arrows correspond with our classical notion of posterior probabilities. The composition operation corresponds with the the chain rule of probability theory.

## Relationship with the classical notions

Classically, when posteriors are introduced, they are only defined after a joint probability has been chosen, and then you will see a definition that looks like “”. I’ll try to relate what’s written here, to this more classical derivation of a posterior probability.

Let and be two measurable spaces. There are two natural projections on to consider:

Given a posterior measure there is a unique map such that :

This map relates a posterior measure to a joint measure, and manifests via the formula This describes the classical relationship between a posterior density and joint. Translating this over to probabilities is a trivial matter of taking the rays of the everything in sight.

The spirit in which a posterior is defined in this post is quite different. Typically, one views posterior probabilities as derivations from a pre-chosen joint probability. In contrast, in this category theoretic picture, the posteriors are entities which exist independently of choosing any joint probability.

#### Bayes’ theorem?

Seems trivial. We just note that we can swap the role of and .

### Diffusion and Markov processes

A Markov process, in this context, is nothing but an arrow, from to itself. A hidden markov model is nothing but a tuple , where and , is a measuraeable map to a space of observables. Diffusion results from the observation that is generically not invertible. My guess is that , is invertible if and only if for some measurable automorphism .

## Bayesian nets

With all these diagrams and arrows being drawn, it’s tempting to wonder “What does this have to do with probabilistic graphical models and Bayesian networks”. Perhaps there is a relation, but it might not resemble what you (or at least I) would have imagined.

The arrows of a Bayesian network are **not** posteriors. The arrows of a Bayesian network represent the flow of information in a computation graph.
This is probably a good time to clear up another misconception.
Bayesian networks are **not** generalizations of computation graphs.
The reverse is true.
Bayesian networks are **special cases** of computation graphs.
They correspond to the scenario where all the nodes are probability distributions.

What category theory has to offer to the world of computation graphs is the notion of composition. Given two computation graphs with a single source node and a single target node, we can compose them to get another computation graph with a single source node and a single target node. The composition corresponds with the composition operation in . After all, these are computation graphs for posterior probabilities.

More generally, we can consider graphs with multiple source nodes, and multiple target nodes, and there is a notion of higher order composition from higher-order category theory which applies in this scenario.

But now I’ve gone so far beyond things I’m qualified to talk about, that I can’t even …

The possibility of physical and mental collapse is now very real. No sympathy for the Devil, keep that in mind. Buy the ticket, take the ride.” ― Hunter S. Thompson, Fear and Loathing in Las Vegas