Merge branch 'adds-outlier-functions' of https://github.com/CartoDB/crankshaft into adds-outlier-functions

This commit is contained in:
Andy Eschbacher 2016-09-29 11:11:36 -04:00
commit f11982f531
2 changed files with 13 additions and 6 deletions

View File

@ -1,16 +1,22 @@
SET client_min_messages TO WARNING;
\set ECHO none
outlier|rowid outlier|rowid
t|11 t|11
t|16 t|16
t|17 t|17
(3 rows)
outlier|rowid outlier|rowid
t|16 t|16
t|17 t|17
(2 rows)
outlier|rowid outlier|rowid
t|8 t|8
t|11 t|11
t|16 t|16
(3 rows)
outlier|rowid outlier|rowid
t|8 t|8
t|9 t|9
t|11 t|11
t|15 t|16
(4 rows)

View File

@ -19,7 +19,7 @@ WITH a AS (
ARRAY[1,3,2,3,5,1,2,32,12, 3,57, 2, 1, 4, 2,100,-100]::numeric[] As vals, ARRAY[1,2,3,4,5,6,7, 8, 9,10,11,12,13,14,15, 16, 17]::int[] As ids ARRAY[1,3,2,3,5,1,2,32,12, 3,57, 2, 1, 4, 2,100,-100]::numeric[] As vals, ARRAY[1,2,3,4,5,6,7, 8, 9,10,11,12,13,14,15, 16, 17]::int[] As ids
), b As ( ), b As (
SELECT SELECT
(cdb_StdDevOutlier(vals, 1.0, ids)).* (cdb_crankshaft.cdb_StdDevOutlier(vals, 1.0, ids)).*
FROM a FROM a
ORDER BY ids) ORDER BY ids)
SELECT * SELECT *
@ -33,7 +33,7 @@ WITH a AS (
ARRAY[1,2,3,4,5,6,7, 8, 9,10,11,12,13,14,15, 16, 17]::int[] As ids ARRAY[1,2,3,4,5,6,7, 8, 9,10,11,12,13,14,15, 16, 17]::int[] As ids
), b As ( ), b As (
SELECT SELECT
(CDB_StdDevOutlier(vals, 2.0, ids)).* (cdb_crankshaft.CDB_StdDevOutlier(vals, 2.0, ids)).*
FROM a FROM a
ORDER BY ids) ORDER BY ids)
SELECT * SELECT *
@ -63,7 +63,7 @@ WITH a AS (
ARRAY[1,2,3,4,5,6,7, 8, 9,10,11,12,13,14,15, 16, 17]::int[] As ids ARRAY[1,2,3,4,5,6,7, 8, 9,10,11,12,13,14,15, 16, 17]::int[] As ids
), b As ( ), b As (
SELECT SELECT
(CDB_PercentOutlier(vals, 2.0, ids)).* (cdb_crankshaft.CDB_PercentOutlier(vals, 2.0, ids)).*
FROM a FROM a
ORDER BY ids) ORDER BY ids)
SELECT * SELECT *
@ -79,7 +79,8 @@ WITH a AS (
SELECT unnest(vals) As v, unnest(ids) as i SELECT unnest(vals) As v, unnest(ids) as i
FROM a FROM a
) )
SELECT CDB_StaticOutlier(v, 11.0), i SELECT cdb_crankshaft.CDB_StaticOutlier(v, 11.0) As outlier, i As rowid
FROM b FROM b
WHERE CDB_StaticOutlier(v, 11.0) is True WHERE cdb_crankshaft.CDB_StaticOutlier(v, 11.0) is True
ORDER BY i; ORDER BY i;