Suppose we have three sets $A, B,C$ and a span $S := A \leftarrow C \rightarrow B$. There is a special case when the data of the span $S$ exactly specifies a function $f: A \rightarrow B$. In every other case, we have some data that may be used to define a function. It's a bit like a probabilistic model of a function or "data" about a function. What I am wondering is whether or not we can do something like a regression that takes spans to functions in some precise way, the same way one might regress a linear function between two data columns. I have gone back and forth as to whether this is possible. Since each arm of the span can be seen as a multiset, we might have a notion of addition over the range elements like this:


$ \{ (a,b), (a,c),(a,b),(a,c) \} \rightarrow \{ 2(a,b), 2(a,c) \} $


Or


$ \{ (a,b), (a,c),(a,b),(a,c) \} \rightarrow (a, \{ 2b, 2c \} )$


What we don't have is a way to map a mixture of ordered pairs to a single ordered pair thus producing the critical regression.


This is reminiscent of the Kleisli category of the multiset monad which is what I was thinking about before landing on this specific question in this post. There is a natural transformation from the mulitset monad to the monad of measures of finite support, which itself has a Kleisli category. Perhaps there is a way to push the notion of averaging from the measures monad Kleisli Cat down to the Kleisli Cat of the multiset monad.


Edit:
A span does not have to give data about every element of the domain, and since there is no information like a metric or topology to extend local data to neighbouring elements, it seems like this is impossible. However, perhaps we can define a partial function from the data based on just those elements in the domain that the span addresses.



Is it possible to regress an arbitrary function from a span?
There is no natural way to convert a span $A\leftarrow C\rightarrow B$ into a (partial) function $f:A\to B$ if, whenever an $a\in A$ is connected to some element(s) of $B$ by the span, $f(a)$ must be one of those elements. 


Consider the case where $A=B=\{1,2,3\}$, where $C=\{(1,2),(1,3),(2,1),(2,3),(3,1),(3,2)\}$, and where the maps in the span are the two projections. Then the span is invariant under the obvious action of the symmetric group $S\_3$, but no $f$ of the required sort is invariant under $S\_3$. So any method of converting spans to suitable functions will have to include some distinction between $1$, $2$, and $3$ that is not in the given span. In other words, the method cannot be natural.


