Subject | Re: [firebird-support] Standard Deviation |
---|---|
Author | Richard Wesley |
Post date | 2008-12-30T00:14:49Z |
On 29 Dec 2008, at 04:54, mielhostens wrote:
aggregators, you can use:
STDEV
(CASE WHEN COUNT(%1) > 1 THEN
SQRT((COUNT(%1) * SUM(POWER(%1,2)) - POWER(SUM(%1), 2) ) /
(COUNT(%1)*(COUNT(%1) - 1)))
ELSE CAST(NULL AS DOUBLE PRECISION) END)
STDEVP
(CASE WHEN COUNT(%1) > 0 THEN
SQRT((COUNT(%1) * SUM(POWER(%1,2)) - POWER(SUM(%1), 2) ) /
(POWER(COUNT(%1),2)))
ELSE CAST(NULL AS DOUBLE PRECISION) END)
VAR
(CASE WHEN COUNT(%1) > 1 THEN
((COUNT(%1) * SUM(POWER(%1,2)) - POWER(SUM(%1), 2) ) /
(COUNT(%1)*(COUNT(%1) - 1)))
ELSE CAST(NULL AS DOUBLE PRECISION) END)
VARP
(CASE WHEN COUNT(%1) > 0 THEN
((COUNT(%1) * SUM(POWER(%1,2)) - POWER(SUM(%1), 2) ) /
(POWER(COUNT(%1),2)))
ELSE CAST(NULL AS DOUBLE PRECISION) END)
HTH,
________________________________________________________
Richard Wesley Senior Software Developer Tableau
Software
Visit: http://www.trytableau.com/now.html
> Anybody who knows if there is a UDF or stored procedure to calculateYou can't create plug-in aggregators. For the common statistical
> the standard deviation of a variable column?
aggregators, you can use:
STDEV
(CASE WHEN COUNT(%1) > 1 THEN
SQRT((COUNT(%1) * SUM(POWER(%1,2)) - POWER(SUM(%1), 2) ) /
(COUNT(%1)*(COUNT(%1) - 1)))
ELSE CAST(NULL AS DOUBLE PRECISION) END)
STDEVP
(CASE WHEN COUNT(%1) > 0 THEN
SQRT((COUNT(%1) * SUM(POWER(%1,2)) - POWER(SUM(%1), 2) ) /
(POWER(COUNT(%1),2)))
ELSE CAST(NULL AS DOUBLE PRECISION) END)
VAR
(CASE WHEN COUNT(%1) > 1 THEN
((COUNT(%1) * SUM(POWER(%1,2)) - POWER(SUM(%1), 2) ) /
(COUNT(%1)*(COUNT(%1) - 1)))
ELSE CAST(NULL AS DOUBLE PRECISION) END)
VARP
(CASE WHEN COUNT(%1) > 0 THEN
((COUNT(%1) * SUM(POWER(%1,2)) - POWER(SUM(%1), 2) ) /
(POWER(COUNT(%1),2)))
ELSE CAST(NULL AS DOUBLE PRECISION) END)
HTH,
________________________________________________________
Richard Wesley Senior Software Developer Tableau
Software
Visit: http://www.trytableau.com/now.html