Skip to content

Commit

Permalink
Merge pull request #145 from CartoDB/fix-cdb_stats-test
Browse files Browse the repository at this point in the history
Do not use random() for the distribution to test CDB_Stats functions
  • Loading branch information
Raul Ochoa committed Sep 9, 2015
2 parents c460b59 + 1853ee6 commit d67f097
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions test/CDB_StatsTest.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@
-- 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
WITH dist AS (
SELECT generate_series(0,10000)::numeric / 10000.0 i
)

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
SELECT
abs(CDB_Kurtosis(array_agg(i)) + 1.2) < 1e-3 AS kurtosis,
abs(CDB_Skewness(array_agg(i))) < 1e-3 AS skewness
FROM dist;

set client_min_messages to NOTICE;

0 comments on commit d67f097

Please sign in to comment.