Re: [HACKERS] Standard Deviation function.

From: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>
To: stuporg(at)erols(dot)com (Stupor Genius)
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] Standard Deviation function.
Date: 1998-06-05 01:55:07
Message-ID: 199806050155.VAA07828@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)candle(dot)pha(dot)pa(dot)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)

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Stupor Genius 1998-06-05 03:22:09 RE: [HACKERS] Standard Deviation function.
Previous Message Stupor Genius 1998-06-05 01:35:56 RE: [HACKERS] Standard Deviation function.