[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Warning about accuracy of Array functions in TS2000i



PureBytes Links

Trading Reference Links

> I "HEAR" everyone, but can someone "SHOW ME" how significant the
> difference is ? 

This is not exactly rocket science.  TS single precision numbers are 
limited to about 6 1/2 digits of precision, by definition.  If you do 
ANYthing, ANYTHING that requires more accuracy than that, you're 
hosed.

Very simple example:

        value1 = 54321;
        value2 = value1*value1;
        print(value2);

Value2 = 2950770944.  Now try it in Excel or in your trusty HP 
calculator.  The right answer is 2950771041.

Here's another one that approximates what functions like StdDev do:

        value1=12345;
        value2=23451;
        value3=34512;
        value4=45123;
        value5=51234;
        
        value6 = value1*value1 + value2*value2 + value3*value3 
                  + value4*value4 + value5*value5;
        value7 = SquareRoot(value6);
        
        print(value7:5:5);

TS says 80959.50000.  Excel says 80959.4618.

So it's clear the single precision result is wrong, but it's very 
close.  And if "very close" is good enough for you, then don't worry 
about the single precision variables.

But what if you start doing things like looking at the differences 
between two StdDev values?  Then "very close" might get you into a 
lot of trouble.

If you do complex calculations, which many system designers do 
(sometimes without being aware of it because they don't think about 
what functions like StdDev or correlation do), then TS may very well 
be giving you the wrong answers.  Depending on the type of analysis 
you do, this inaccuracy can kill you.

If you're satisfied with those wrong answers, or if ballpark 
estimates are good enough for you, you're fine.  I can't show you the 
difference because "close" is apparently "close enough" for you.  

Just be aware that your code may be a lot fussier about the 
definition of "close enough" than you are.

Gary