Re: Covariance Function in Postgresql?? - Mailing list pgsql-general

From Joe Conway
Subject Re: Covariance Function in Postgresql??
Date
Msg-id 3E9353C5.2050404@joeconway.com
Whole thread Raw
In response to Covariance Function in Postgresql??  (jonathan.nichols@sbcglobal.net (Jonathan Nichols))
List pgsql-general
Jonathan Nichols wrote:
>     I'm looking to take the covariance of two columns in a postgresql
> table.  I know there are sum, average, variance and standard deviation
> functions.  Is there a covariance function hiding somewhere?

There is no built in aggregate for covariance. In fact, there is no
notion of an aggregate that works across two columns (at least that I'm
aware of). But you could use PL/R to create a function that executes a
sql statement and calculates covariance. For more on PL/R, see:
http://www.joeconway.com/

HTH,

Joe


pgsql-general by date:

Previous
From: Joe Conway
Date:
Subject: Re: Arrays ... need clarification....
Next
From: Martijn van Oosterhout
Date:
Subject: Re: extracting time from a timestamp with time zone field