From 1c66fbf0863c63e6a567338b1895c43c5b24b29b Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Sun, 15 Apr 2012 10:16:06 -0700 Subject: [PATCH] random: adding some tests for the random distributions. --- basis/random/random-tests.factor | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/basis/random/random-tests.factor b/basis/random/random-tests.factor index fc545a9247..f22b02a147 100644 --- a/basis/random/random-tests.factor +++ b/basis/random/random-tests.factor @@ -34,6 +34,9 @@ IN: random.tests [ ] [ [ 100 random-bytes ] with-system-random drop ] unit-test +{ t t } +[ 50000 [ 0 1 normal-random-float ] replicate [ mean 0 .2 ~ ] [ std 1 .2 ~ ] bi ] unit-test + { t } [ 50000 [ .15 exponential-random-float ] replicate [ mean ] [ std ] bi .2 ~ ] unit-test @@ -45,3 +48,31 @@ IN: random.tests 50000 [ 1 3 pareto-random-float ] replicate [ mean ] [ std ] bi [ 1.5 .3 ~ ] [ 3 sqrt 2 / .3 ~ ] bi* ] unit-test + +{ t t } +[ + 50000 [ 2 3 gamma-random-float ] replicate + [ mean 6 .2 ~ ] [ std 2 sqrt 3 * .2 ~ ] bi +] unit-test + +{ t t } +[ + 50000 [ 2 3 beta-random-float ] replicate + [ mean 2 2 3 + / .2 ~ ] + [ std 2 sqrt 3 sqrt + 2 3 + dup 1 + sqrt * / .2 ~ ] bi +] unit-test + +{ t } +[ 50000 [ 3 4 von-mises-random-float ] replicate mean 3 .2 ~ ] unit-test + +{ t t } +[ + 50000 [ 2 7 triangular-random-float ] replicate + [ mean 2 7 + 2 / .2 ~ ] [ std 7 2 - 2 6 sqrt * / .2 ~ ] bi +] unit-test + +{ t t } +[ + 50000 [ 2 3 laplace-random-float ] replicate + [ mean 2 .2 ~ ] [ std 2 sqrt 3 * .2 ~ ] bi +] unit-test