moving-average

Cumulative sums, moving averages, and SQL "group by" equivalents in R

What's the most efficient way to create a moving average or rolling sum in R? How do you do the rolling function along with a "group by"? ...

How to best maintain a database of average time-related values?

I want to store the average values of some data that is occasionally generated by users, which I then use in my application to predict future data. Now the problem I have is that this data may grossly change during the day - so for example users coming in at night time may generate much lower values then users coming in during the mornin...

Running average in Python

Is there a pythonic way to build up a list that contains a running average of some function? After reading a fun little piece about Martians, black boxes, and the Cauchy distribution, I thought it would be fun to calculate a running average of the Cauchy distribution myself: import math import random def cauchy(location, scale): ...

How do you use a moving average to filter out accelerometer values in iPhone OS

I want to filter the accelerometer values using a moving average, how is this done? Thanks ...

Simple Moving Average for stock prices

I was playing with ActiveQuant FinancialLibrary SimpleMovingAverage function SMA() below: Is there an error in the algo below, where it calculates the average by looking "into the future" ( as it does i < (period + skipdays) ) ? public static double SMA(int period, double[] vals, int skipdays) { double value = 0.0; for (int i =...

Smoothing values over time: moving average or something better?

I'm coding something at the moment where I'm taking a bunch of values over time from a hardware compass. This compass is very accurate and updates very often, with the result that if it jiggles slightly, I end up with the odd value that's wildly inconsistent with its neighbours. I want to smooth those values out. Having done some readin...

Efficient computation of "variable (number of points included)" moving average in R

Hi everybody, I'm trying to implement a variable exponential moving average on a time series of intraday data (i.e 10 seconds). By variable, I mean that the size of the window included in the moving average depends on another factor (i.e. volatility). I was thinking of the following: MA(t)=alpha(t)*price(t) + (1-alpha(t))MA(t-1), whe...