like this might work:
pseudocode:
select (currentday.num +
(select num from currentday
where theday = dateadd(d,1,theday)) +
(select num from currentday
where theday = dateadd(d,-1,theday)) ) / 3
as rollingaverage from currentday
where currentday.theday between #startdate# and #enddate#
not tested of course and the dateadd() function is going to be
database server specific... and it might become unwieldy and slow with
a lot of data, but that'd be where I'd start.
> Ah, I see. This is a cool technique. I don't suppose it's
> easy enough
> to do in SQL? Something to think about I guess. :)
> -Raymond
> On Mon, 12 Jul 2004 12:33:42 -0400, Jerry Johnson
> <[EMAIL PROTECTED]> wrote:
>> To smooth a curve, you can take a rolling average (by
>> taking the average of the data point and a couple of
>> datapoints adjacent)
>>
>> for example
>>
>> 3day - take the day before, the day, and the day after,
>> and average them (db+d+da)/3
>>
>> 1day 3day 5day
>>
>> s 2
>> m 2 1.66
>> t 1 1.66 1.8
>> w 2 1.66 2.0
>> t 2 2.33 2.2
>> f 3 2.66 2.8
>> s 3 3.33 3.0
>> s 4 3.33 3.2
>> m 3 3.33 5.4
>> t 3 6.66 5.4
>> w 14 10 5.0
>> t 3 6.33 5.0
>> f 2 2.66 4.8
>> s 3 2.33
>> s 2
>>
>> You'll see that the 5 day is mush smoother a curve than
>> the 3day, which is smoother than the spiky day version.
>>
>> Does this help?
>> Jerry Johnson
>>
>> >>> [EMAIL PROTECTED] 07/12/04 12:06PM >>>
>> What do you mean by moving average? Just show the last N
>> days in a
>> range you mean? (That actually would help me.)
>>
>>
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]
