Question: Disclaimer: No, I didn't find any obvious answer, contrary to what I expected!

When looking for code examples wrt. the arithmetic mean, the first several examples I can turn up via Google seem to be defined such that the empty sequence generates a mean value of `0.0`. (eg. [here](https://rosettacode.org/wiki/Averages/Arithmetic_mean#C.2B.2B) and [here](https://stackoverflow.com/a/1346890/321013) ...)

Looking at Wikipedia however, the [Arithmetic mean](https://en.wikipedia.org/wiki/Arithmetic_mean#Definition) is defined such that an empty sequence would yield `0.0 / 0` -- 

```
 A = 1/n ∑[i=1 -> n](a[i])

```

-- so, possibly, [that is NaN](https://en.wikipedia.org/wiki/NaN#Operations_generating_NaN) in the general case.

So if I write a utility function that calculates the arithmetic mean of a set of floating point values, should I, in the general case:

* return `0.` for the empty sequence?
* return `(Q)NaN` for the empty sequence?
* "throw an exception" in case of empty sequence?

Answer: 
Mathematically, it's undefined as the denominator is zero.

Because the behaviour of integer division by zero is *undefined* in C++, throw an exception if you're working in integral types.

If you're working in IEEE754 floating point, then return NaN since the *numerator* will also be zero. (+Inf would be returned if the numerator is positive, and -Inf if the numerator is negative).
I like defensive coding, so I would throw an exception. You can make it either a specific exception (like empty\_sequence\_exception) or a division by 0, since the divider is the length of the sequence which is 0.

0.0 is debatable since there is no data (sequence).