Standard Deviation function. - Mailing list pgsql-hackers

From Chris Albertson
Subject Standard Deviation function.
Date
Msg-id 357747F2.A256B26C@topdog.logicon.com
Whole thread Raw
Responses RE: [HACKERS] Standard Deviation function.  ("Stupor Genius" <stuporg@erols.com>)
List pgsql-hackers
Hello,

I really need a Standard Deviation aggregate function so I will
try to write one.

I know about the man pages for "create aggregate" and "create
function".  Is there something else I should look at?
Just a few pointers could save me a few hours of hunting around.
All advice accepted.

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.  I could use three static variables and have the final
function ignore its input and use the static vars instead.  This
will likely blow up if the new Standard Deviation aggregate is
used twice in the same select.

Any hints or advice??

If someone has this done already let me know.

I may want do a "median" aggregate function too as I'll need that
later.  This would require private storage and a sort.

Could you cc me at both addresses below as I move around between
them

Thanks,

--
--Chris Albertson

  chrisja@jps.net
  chris@topdog.logicon.com                Voice:  626-351-0089  X127
                                            Fax:  626-351-0699

pgsql-hackers by date:

Previous
From: fue48@hk.super.net (USA Publishing Co.)
Date:
Subject: Wanted Home Product Assemblers
Next
From: "Stupor Genius"
Date:
Subject: RE: [HACKERS] Standard Deviation function.