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

Re: Easy Language Math Precision



PureBytes Links

Trading Reference Links

The Omega Man wrote:
 
> > > > Do we need to go out to the nth decimal place to 

<snip, snip> 

> No... such a build up of errors is highly unlikely.  The more likely
> circumstance is that errors offset one another.  Some add and some subtract
> and you end up about where you would have been anyway.

Not true.  As someone has already responded, go take an introductory
course in numerical analysis at your local community college.

<snip, snip> 


Also in this thread, the Jackal <tradejacker@xxxxxxxxx> re-posted an
old message by Bob Fulks, which in part was:

> As a very simple example, the "Average" function supplied with
> TradeStation calculates the average by subtracting the old bar 
> and adding the new bar:
> 
>     Sum = Sum[1] + Price - Price[Length]
> 
> This is done because it is faster than recalculating everything on
> each new bar.
> 
> If there were even a small error on each calculation, the total error
> accumulated after hundreds or thousands of bars could be very
> significant.  As it is, the present accuracy is barely adaquate 
> for many operations.
 

Listen when Bob says that single precision is barely adequate for
many operations.  That is why almost no scientific computation
is done in single precision.

The equation above is a classic example of how NOT to do calculations
of running sums.  Check any classic book on numerical analysis at your
local library, and you will find that very example of bad programming
practice.  Along with an explanation of why not do that, you will 
likely find a description of how much even that bad practice is 
improved by simply using a double precision variable only for SUM.
Now in today's Intel CPU's, the internal floating point registers 
(going all the way back to 8087's) are 80 bits.  If you have a good
compiler to compile a statement like the one above within a tight 
accumulation loop, the compiler will arrange for SUM to be held
in a register while the loop is running and will only store the
result back to main memory after the completion of the loop.  This
fact alone can make a tremendous difference in the results.  But if
such a loop is a small part of a considerably more complicated
algorithm, then you will still need SUM to be double precision.

Anybody know if EL is smart enough to keep intermediate results
in the floating point registers?  Knowing Omega, I doubt it.  All
the more reason to use a "standard" language for programming your
trading systems.

Rod (the ex-numerical analyst)