"Greg Ewing" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> I don't think you're doing anyone any favours by trying to protect
> them from having to know about these things, because they *need* to
> know about them if they're not to write algorithms that seem to
> work fine on tests but mysteriously start producing garbage when
> run on real data,

I agree.  Here was my 'kick-in-the-butt' lesson (from 20+ years ago):  the 
'simplified for computation' formula for standard deviation, found in too 
many statistics books without a warning as to its danger, and specialized 
for three data points, is sqrt( ((a*a+b*b+c*c)-(a+b+c)**2/3.0) /2.0). 
After 1000s of ok calculations, the data were something like a,b,c = 
10005,10006,10007.  The correct answer is 1.0 but with numbers rounded to 7 
digits, the computed answer is sqrt(-.5) == CRASH.  I was aware that 
subtraction lost precision but not how rounding could make a theoretically 
guaranteed non-negative difference negative.

Of course, Python floats being C doubles makes such glitches much rarer. 
Not exposing C floats is a major newbie (and journeyman) protection 
feature.

Terry Jan Reedy



_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to