Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: exponential average

Re: exponential average

From: Brian E Dick <bdick_at_cox.net>
Date: Mon, 16 Dec 2002 15:37:30 GMT
Message-ID: <_qmL9.32292$0b.1285409@news2.east.cox.net>


BTW, the table for the query below is

create table daily_hits
(hit_day date
,hits number)

hit_day is truncated to the day

To verify the query I ran it for a=0 and a=1. Those queries yielded exp_avg=a.hits and exp_avg=avg(b.hits), respectively. So, I am confident that this query is correct.

"Brian E Dick" <bdick_at_cox.net> wrote in message news:Q4mL9.32187$0b.1277768_at_news2.east.cox.net...
> I believe the following does it for n=60 and a=0.5.
>
> select a.hit_day
> , sum(b.hits * power(0.5, a.hit_day - b.hit_day))
> / sum(power(0.5, a.hit_day - b.hit_day)) exp_avg
> from daily_hits a
> , daily_hits b
> where b.hit_day between a.hit_day - 59 and a.hit_day
> group by a.hit_day
>
>
> "Laly" <laly.kattoor_at_freesbee.fr> wrote in message
> news:4ec940f.0212111138.1658f90d_at_posting.google.com...
> > Hi,
> >
> >
> > Does anyone know how i can compute an exponential average using
> > analytical functions under Oracle. It is easy to get normal moving
> > average with avg(...) over(partition by ... order by ... rows 60
> > preceding) but how about getting :
> > x(n) + a*x(n-1) + a^2*x(n-2)+....
> > -----------------------------------
> > 1 + a + a^2 + ...
> >
> >
> > More generally, is it possible to compute a column using the value
> > just computed in the row before ? Something like x(n+1) = f(x(n))
> > where n is the number of the row ?
> >
> >
> > Thanks by advance for any clue.
> >
> >
> > Laly.
>
>
Received on Mon Dec 16 2002 - 09:37:30 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US