Re: [HACKERS] Standard Deviation function. - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: [HACKERS] Standard Deviation function.
Date
Msg-id 199806050155.VAA07828@candle.pha.pa.us
Whole thread Raw
In response to RE: [HACKERS] Standard Deviation function.  ("Stupor Genius" <stuporg@erols.com>)
Responses RE: [HACKERS] Standard Deviation function.  ("Stupor Genius" <stuporg@erols.com>)
List pgsql-hackers
>
> > I really need a Standard Deviation aggregate function...
> >
> > I know about the man pages for "create aggregate" and "create
> > function".  Is there something else I should look at?
> >
> > It seems kind of hard to do with only two state functions unless
> > I "cheat".  I need to keep three values, Count, Sum, and Sum of
> > Squares.
> >
> > Any hints or advice??
>
> I thought about this a long time ago and had an idea but never
> got around to trying to implement it.  I was going to have some
> functions that worked on a structure of two doubles to track
> the sum and square instead of using only one simple type.

I remember talking about this to someone, and the problem is that you
needed the average WHILE scanning through the table, which required two
passes, which the aggregate system is not designed to do.  I may be
wrong on this, though.

--
Bruce Momjian                          |  830 Blythe Avenue
maillist@candle.pha.pa.us              |  Drexel Hill, Pennsylvania 19026
  +  If your life is a hard drive,     |  (610) 353-9879(w)
  +  Christ can be your backup.        |  (610) 853-3000(h)

pgsql-hackers by date:

Previous
From: "Stupor Genius"
Date:
Subject: RE: [HACKERS] Standard Deviation function.
Next
From: "Stupor Genius"
Date:
Subject: RE: [HACKERS] Standard Deviation function.