From 2eaea55041587c4cf46884cc5a7e96fa73bf38c7 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Sun, 23 Jul 2006 06:19:31 +0000 Subject: [PATCH] Added a basic frequency distribution test. Note that in limited samples of 1000 across 5 bins that the distribution is not even. The highest and lowest bin seem to have about half the frequency of the other bins. This is due to the use of the round function. int would make the distribution more even (white) at the cost of not returning the limiting number. --- t/Macro/Splat_random.t | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/t/Macro/Splat_random.t b/t/Macro/Splat_random.t index 902ec86fa..77169645b 100644 --- a/t/Macro/Splat_random.t +++ b/t/Macro/Splat_random.t @@ -28,7 +28,7 @@ use Data::Dumper; ##Note, testing statistical functions is kind of weird. All we really ##need to do is make sure that the macro functions as advertised. -plan tests => 3; +plan tests => 4; unless ($session->config->get('macros')->{'Splat_random'}) { Macro_Config::insert_macro($session, '*', 'Splat_random'); @@ -64,3 +64,16 @@ WHOLE: for (my $i=0; $i<=99; $i++) { ok($wholeNumber, "100 fetches were all whole numbers"); +my @bins = (); +WHOLE: for (my $i=0; $i<=999; $i++) { + my $output = sprintf $macroText, 4; + WebGUI::Macro::process($session, \$output); + ++$bins[$output]; +} + +is(scalar(@bins), 5, "All bins have values on a sample size of 1000"); + +##Early work in analyzing a frequency distribution showed that the highest +##and lowest bin have half the frequency of center bins. Splat_random doesn't +##seem very random +#diag Dumper \@bins;