BUG: Use stable algorithm for _nanvar.
closes #10242

This PR replaces the sum-of-squares algorithm used to compute the variance by a more stable algorithm. The algorithm here is essentially the same as used in numpy 1.8 and up, and I've added a TODO to replace the implementation with a direct call to numpy when that version is the default.

Somewhat counter to the discussion in #10242, I chose not to go with the Welford algorithm, for two reasons: numpy, and the fact that `_nanvar` needs to be able to deal with arrays of different shape, which is tricky to get right in Cython.
