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

RE: Precision Errors



PureBytes Links

Trading Reference Links

>>On an even simpler scale, calculate a simple 1000 bar moving average in TS and compare to Excel or C++.   TS can't even do this with precision to ONE decimal place.<<

There are 2 way to calculate a simple moving average.  The first is to sum all N numbers and take take average, and repeat this on each bar.  According to numerical analysis, this approach has the potential problem that the floating point summing variable might become so large that the exponent component of the next value being added will be off the scale (too small) for the summing variable to see.  At that point, you can attempt to add thousands of more values and nothing happens.  However, this problem will not occur when N<1000, even with single precision. Another drawback of this method is that it is very slow for large N.

The other, and faster way, is to keep the current sum and simply subtract out the value that fell outside the moving window and add the new value that just fell in.  However, this method is susceptible to increasing roundoff error.  After about 1000 cycles, this error becomes significant and mucks up accuracy.

There are two ways to handle this, improve precision (not the Omega way) or write sophisticated algorithms (also not the Omega way).  

- mark jurik



----------
From: 	Neal Falkenberry, CFA
Sent: 	Wednesday, July 18, 2001 4:38 PM
To: 	Bengtsson, Mats; omega-list@xxxxxxxxxx
Cc: 	pierre.orphelin@xxxxxxxxxxxxxx
Subject: 	Precision Errors

<<File: ATT00008.txt>>