pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedRe: variance aggregate function incorrect? Reference Materials reg create aggregate
3+ messages / 3 participants
[nested] [flat]
* variance aggregate function incorrect? Reference Materials reg create aggregate
@ 2002-06-24 22:13 Joseph Syjuco <joseph@asti.dost.gov.ph>
2002-06-24 15:39 ` Re: variance aggregate function incorrect? Reference Materials reg create aggregate Tom Lane <tgl@sss.pgh.pa.us>
2002-06-24 16:16 ` Re: variance aggregate function incorrect? Reference Materials Bruce Momjian <pgman@candle.pha.pa.us>
0 siblings, 2 replies; 3+ messages in thread
From: Joseph Syjuco @ 2002-06-24 22:13 UTC (permalink / raw)
To: pgsql-sql
hi
i needed the variance function ... i dont know if i introduced the wrong
parameters or maybe this variance is not the variance that im looking
for but it doesnt provide the right results
variance=(nEx^2 - (Ex)^2)/(n(n-1))
my sql statement
select variance(answer) from tbl_answer (where answer is of type
integer)
because of this i need to create my own variance aggregate (unless
someone enlightens me on whats happening with the variance aggregate) so
i would like to know if theres anyone who knows a good create aggregate
tutorial (with samples) ... all i got from google so far is the
reference from ninthwonder.com
TIA
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: variance aggregate function incorrect? Reference Materials reg create aggregate
2002-06-24 22:13 variance aggregate function incorrect? Reference Materials reg create aggregate Joseph Syjuco <joseph@asti.dost.gov.ph>
@ 2002-06-24 15:39 ` Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 0 replies; 3+ messages in thread
From: Tom Lane @ 2002-06-24 15:39 UTC (permalink / raw)
To: Joseph Syjuco <joseph@asti.dost.gov.ph>; +Cc: pgsql-sql
Joseph Syjuco <joseph@asti.dost.gov.ph> writes:
> i needed the variance function ... i dont know if i introduced the wrong
> parameters or maybe this variance is not the variance that im looking
> for but it doesnt provide the right results
> variance=(nEx^2 - (Ex)^2)/(n(n-1))
That's what I'd expect it to do, all right. Please define "doesnt
provide the right results".
regards, tom lane
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: variance aggregate function incorrect? Reference Materials
2002-06-24 22:13 variance aggregate function incorrect? Reference Materials reg create aggregate Joseph Syjuco <joseph@asti.dost.gov.ph>
@ 2002-06-24 16:16 ` Bruce Momjian <pgman@candle.pha.pa.us>
1 sibling, 0 replies; 3+ messages in thread
From: Bruce Momjian @ 2002-06-24 16:16 UTC (permalink / raw)
To: Joseph Syjuco <joseph@asti.dost.gov.ph>; +Cc: pgsql-sql
Joseph Syjuco wrote:
> hi
> i needed the variance function ... i dont know if i introduced the wrong
> parameters or maybe this variance is not the variance that im looking
> for but it doesnt provide the right results
>
> variance=(nEx^2 - (Ex)^2)/(n(n-1))
> my sql statement
> select variance(answer) from tbl_answer (where answer is of type
> integer)
>
> because of this i need to create my own variance aggregate (unless
> someone enlightens me on whats happening with the variance aggregate) so
> i would like to know if theres anyone who knows a good create aggregate
> tutorial (with samples) ... all i got from google so far is the
> reference from ninthwonder.com
Uh, I tried this:
test=> select variance(relnatts) from pg_class;
variance
---------------
24.4259169884
(1 row)
Not sure if it is the right number or not. Have you tried taking the
square root and see if that number is correct.
The docs say:
The variance is the square of the standard deviation. The
supported data types and result types are the same as for
standard deviation.
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2002-06-24 22:13 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-06-24 22:13 variance aggregate function incorrect? Reference Materials reg create aggregate Joseph Syjuco <joseph@asti.dost.gov.ph>
2002-06-24 15:39 ` Tom Lane <tgl@sss.pgh.pa.us>
2002-06-24 16:16 ` Re: variance aggregate function incorrect? Reference Materials Bruce Momjian <pgman@candle.pha.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox