by hackandthink · 2y ago · 0 comments
It goes from a value x to a probability distribution of Y.
It is more general than a non-deterministic computation. You get a list of results with weights attached to it. (ignoring continuous distributions)
Grouping can be regarded as a non-deterministic computation.
It goes from a value x to a list of Y.
Computing averages or other aggregations from lists or distributions is another step.
https://dennybritz.com/posts/probability-monads-from-scratch...
https://github.com/mattearnshaw/lawvere/blob/master/pdfs/196...
Can you elaborate on that? I don't see how grouping can be a non-deterministic computation. When you compute the groups of a set you always get the same ones, or am I missing something?
The groups are deterministic. The non-determinism lies in which element of the group is then selected.
"Calculate an even number"
equals
"Take any element from the group of even numbers"
https://www.schoolofhaskell.com/school/starting-with-haskell...
Anecdote time: some weeks ago I had a bug for this reason. I was doing a groupby + select the first element, and since the first element is not always the same I was getting some weird results. I solved it by sorting the group elements before selecting the first element.