A very simple and useful Weighted Moving Average can be had without 
keeping a number of samples on hand.

    WMA = (WMA + NewSample) / 2

I.e. the new WMA is the average of the current WMA and the value of the 
new sample. This weights successive samples by decreasing powers of 2: 
Current sample weight=1/2, previous sample weight=1/4, next 
previous=1/8, etc.

The WMA tracks changes well. Other weightings can be had by applying 
coefficients to the elements:

    WMA = (A*WMA + B*NewSample) / (A+B)

It can be seen that the original strategy is an instance of the general 
formula with coefficients of 1 for A and B.

-R.

npearson99 wrote:
> I'm trying to calculate a moving average in sqlite through sqliteman.
>
> I'm just trying to get some of the analytic functions to work, but I keep
> getting a syntax error.  I got this from a sql wiki page, so I hope
> something like this will work.
>
> select sum(salary) over 
> (partition by months order by minutes rows between unbounded preceding and
> current row)
> from tblSalaryData
>
> I get an error by partition.  I know this doesn't give me the moving
> average, I'm just trying to get the "over" statement part to register.
>
> Any ideas?
>
> Thanks!
>   

-- 
Regards, Rod Dav4is / P.O. Box 118 / Hyde Park, NY 12538 / USA
Genealogy, et Cetera: http://freepages.rootsweb.ancestry.com/~dav4is/
538 ancestral & collateral families, mostly 17°-19° century 
New England & European roots. Total population: 136,000+
Annex: http://www.gencircles.com/users/dav4is/
email: [email protected]
A Democrat, a Republican and a giraffe walk into a bar. The 
bartender looks up from his want ads and says, "What is this, a joke?"
-unknown

_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to