Обсуждение: Covariance Function in Postgresql??

Поиск
Список
Период
Сортировка

Covariance Function in Postgresql??

От
jonathan.nichols@sbcglobal.net (Jonathan Nichols)
Дата:
Hello,

    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?

thanks,

jon

Re: Covariance Function in Postgresql??

От
Joe Conway
Дата:
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