middle(x, y)
Compute the middle of two numbers x and y, which is equivalent in both value and
type to computing their mean ((x + y) / 2).
julia> middle(now(), now())
ERROR: MethodError: no method matching middle(::DateTime, ::DateTime)
julia> middle('a','c')
ERROR: MethodError: no method matching middle(::Char, ::Char)
Char seems likely.
For DateTime, which has 1 ms precision, I’m not sure what the rounding rules are.
For Date, which has 1 day precision, likewise.
Are there other types that should have these methods?
I don’t see that statistics applies only to numbers. Affine quantities like Dates and Fahrenheits can theoretically all compute midpoints by something like (though not exactly)
middle(x,y) = (x - y) / 2 + y
instead of
(x + y) / 2
I propose it would give an InexactError, as would middle(today, tomorrow).
On the other hand, middle(yesterday, tomorrow) == today and middle(32.0°F, 33.0°F) == 32.5°F where currently it fails on division.