Has any work been done on generalizing statistical computations to arbitrary structures? I was wondering what would be necessary for them to be meaningful. For example, the mean of a set is the "sum" of the set (probably a commutative monoid, since finite multisets are "free commutative monoids"?) but then how would one deal with the division by the size of the set?

I apologize if this isn't a very well-formed idea, but I've been playing with generalizations of common "real number" things to see what kinds of structures they'd need.

I tagged this with group theory even though I'm not sure groups would be involved (except maybe the division aspect of the sum, but that's division by a natural?) because I wasn't able to find a general "algebra" tag.