[Python-Dev] return type of __complex__

Stephen J. Turnbull stephen at xemacs.org
Mon Oct 22 08:13:05 CEST 2012


Chris Angelico writes:

 > There really aren't that many situations where a program will be
 > completely oblivious of complex/imaginary numbers and be able to
 > encounter them... are there?

Stats.  Happens in naive student programs with naive student models.

Specifically, in computing variance or SSE, it's often convenient to
subtract the square of the mean from the sum of the squares.  With
ill-conditioned data (specifically, perfectly multicollinear series
that arise when you do a linear regression on an accounting identity)
I occasionally[1] see a negative variance in submitted output.  That
implies a complex standard deviation.

Unlike Inland Revenue or even the IRS, third-rate MBA students are
completely able to take complex results in stride.  That's the value
of a higher education! ;-)

Of course regressing an accounting identity is a (big) mistake anyway,
but the students are more likely to argue with a professor than with a
computer.

You might also see this in various applications in computational
geometry.

Footnotes: 
[1]  Every couple of years.



More information about the Python-Dev mailing list