cartodb-postgresql/test/CDB_StatsTest.sql

17 lines
487 B
MySQL
Raw Normal View History

2015-09-03 10:19:07 +08:00
-- continuous uniform distribution has kurtosis = -6/5, skewness = 0.0
-- http://mathworld.wolfram.com/UniformDistribution.html
set client_min_messages to ERROR;
2015-09-03 10:19:07 +08:00
With dist As (
2015-09-03 10:35:03 +08:00
SELECT random()::numeric As val
FROM generate_series(1,50000) t
2015-09-03 10:35:03 +08:00
)
2015-09-03 10:19:07 +08:00
SELECT
2015-09-03 10:35:03 +08:00
-- 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;