$\def\unit{{\rm unit}}\def\join{{\rm join}}$It's well known that (discrete) probability distributions form a monad. Specifically, if we let $PX$ be the set of discrete probability distributions on elements of $X$, and notate them as a set of pairs $(x,p)$ such that $\sum p=1$, then we have natural transformations

$$\begin{align} \unit : X & \to PX \\ \unit : x & \mapsto \{ (x,1) \} \\ \\ \join: P(PX) & \to PX \\ \join: D & \mapsto \{(y,pq)| (x,p) \in D, (y,q)\in x \} \end{align}$$

that satisfy the monad laws.

Can probability distributions be made into a comonad as well? For that, we would need to provide natural transformations

$$\begin{align} {\rm counit} : PX & \to X \\ {\rm cojoin} : PX & \to P(PX) \end{align}$$

that satisfy the comonad laws. It seems that the role of counit can be played by mathematical expectation (as long as $X$ is an $\mathbb{R}$-module), but in that case what is the correct definition of cojoin?


Edit:

Zhen Lin pointed out in the comments that if you want to have counit being expectation, then you need an $\mathbb{R}$-module structure on $PX$ as well as on $X$. The module operations on $PX$ are inherited from those on $X$ in the following way:

Addition

$$D_1 + D_2 = \{ (x+y,pq) | (x,p)\in D_1, (y,q)\in D_2\}$$

Multiplication by a scalar

$$qD = \{ (qx,p) | (x,p)\in D \}$$


As you point out, in order for having a counit $PX\to X$, you need $X$ to be equipped with an operation of taking "midpoints" of some kind. Otherwise, it is not clear what that map may be. In other words, it would work if you want $X$ to be an algebra over $P$.

Now, note that the algebras of the distribution monad $P$ have been characterized, they are sometimes called "convex spaces", e.g. here. A natural choice of objects on which $P$ induces a comonad is then just restricting to the category of $P$-algebras (where $P$ is considered as a monad). The counit is then the algebra structure map $PX\to X$, which forms convex combinations. Note that if we want such map to be natural, then we have to restrict the morphisms too: only the morphisms of $P$-algebras would do. In other words, $P$ induces a comonad on the Eilenberg-Moore category $\mathrm{Set}^P$.

This way, $P$ induces a comonad in the following way. Let's first see this abstractly. The forgetful functor $\mathrm{Set}^P\to\mathrm{Set}$ has a left-adjoint induced by $P$. Every adjunction induces a monad as well as a comonad: the monad on $\mathrm{Set}$ is just $P$, and the comonad that you get on $\mathrm{Set}^P$ is the one we want.

Now more concretely: the functor of the monad is really just $P$, except that we consider it on $\mathrm{Set}^P$. The counit of the monad is the map we just explained, and the comultiplication $PX\to PPX$ is given by $P\delta$, where $\delta:X\to PX$ is the unit of the old monad.

Note that in general $PX$ is not a vector space, but it's still a convex space, so it has a notion of midpoint (as a $P$-algebra, it is a free one). The operation of midpoint is given exactly by the multiplication $\mu:PPX\to PX$ of the monad.