[Python-Dev] nice()
Terry Reedy
tjreedy at udel.edu
Wed Feb 15 01:32:12 CET 2006
More information about the Python-Dev mailing list
Wed Feb 15 01:32:12 CET 2006
- Previous message: [Python-Dev] nice()
- Next message: [Python-Dev] PEP for adding an sq_index slot so that any object, a or b, can be used in X[a:b] notation
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"Greg Ewing" <greg.ewing at canterbury.ac.nz> wrote in message news:43F1B68B.5010604 at canterbury.ac.nz... > 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
- Previous message: [Python-Dev] nice()
- Next message: [Python-Dev] PEP for adding an sq_index slot so that any object, a or b, can be used in X[a:b] notation
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list