Merge pull request #124 from CartoDB/add-kurtosis

Add kurtosis and skewness
This commit is contained in:
Raul Ochoa
2015-09-07 12:11:34 +02:00
4 changed files with 67 additions and 0 deletions

16
test/CDB_StatsTest.sql Normal file
View File

@@ -0,0 +1,16 @@
-- continuous uniform distribution has kurtosis = -6/5, skewness = 0.0
-- http://mathworld.wolfram.com/UniformDistribution.html
set client_min_messages to ERROR;
With dist As (
SELECT random()::numeric As val
FROM generate_series(1,50000) t
)
SELECT
-- does random dist values match within 1% of known values
abs(CDB_Kurtosis(array_agg(val)) + 1.20) < 1e-2 As kurtosis,
abs(CDB_Skewness(array_agg(val)) - 0) < 1e-2 As skewness
FROM dist;
set client_min_messages to NOTICE;

View File

@@ -0,0 +1,3 @@
SET
t|t
SET