This probably belongs on General, but On Fri, Feb 29, 2008 at 9:11 AM, Justin <[EMAIL PROTECTED]> wrote: > Need help and direction creating new aggregate functions. > > We need to add more average functions for both scientific and finical > purposes > > RMS for electrical measurement purposes > Mode for both electrical and finical > Weighted Average finical purposes > Generalized mean for electrical measurement purposes > Geometric mean for electrical measurement purposes > Harmonic mean for electrical measurement purposes > > what would be the best way to create these new functions??
Have you already read the documentation on creating aggregates? Have you tried something and it didn't work, or are you interested in design ideas? I would just knock together something in plpgsql. If you have trouble, send the specific questions to the list. "best" ? C is fastest, etc -- what kind of tradeoffs do you need to satisfy? One thing worth thinking about is using arrays to carry state from one function call to the next in an aggregate; this is how the function used in the average aggregate keeps track of both the running total and the number of rows. The Stdev uses a three item array similarly. > > > ---------------------------(end of broadcast)--------------------------- > TIP 6: explain analyze is your friend > ---------------------------(end of broadcast)--------------------------- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly