really add tests

This commit is contained in:
Andy Eschbacher 2015-09-02 22:35:03 -04:00
parent 07280321ab
commit d00e71309d

View File

@ -2,16 +2,12 @@
-- http://mathworld.wolfram.com/UniformDistribution.html -- http://mathworld.wolfram.com/UniformDistribution.html
With dist As ( With dist As (
SELECT random() As val SELECT random()::numeric As val
FROM generate_series(1,5000000) t FROM generate_series(1,5000000) t
), )
m As (
SELECT avg(val) mn, count(*) cnt, stddev(val) s
FROM dist
)
SELECT SELECT
abs(sum(power(mn - val,4)) / ( cnt * power(s,4)) - 3 + 1.20) < 1e-3 As kurtosis, -- does random dist values match within 1% of known values
abs(sum(power(mn - val,3)) / ( cnt * power(s,3))) < 1e-3 As skewness abs(CDB_Kurtosis(array_agg(val)) + 1.20) < 1e-2 As kurtosis,
FROM dist, m abs(CDB_Skewness(array_agg(val)) - 0) < 1e-2 As skewness
GROUP BY m.cnt, m.mn, m.s FROM dist