fix: Splat_random Macro not so random
This commit is contained in:
parent
f420103b2e
commit
4e2e5e8c78
4 changed files with 27 additions and 18 deletions
|
|
@ -35,6 +35,8 @@
|
||||||
line, which fixed a problem with the WRE monitor, and also enabled us to
|
line, which fixed a problem with the WRE monitor, and also enabled us to
|
||||||
add more complete connectivity testing.
|
add more complete connectivity testing.
|
||||||
- fix: Templates XHTML compliance (Wouter van Oijen / ProcoliX)
|
- fix: Templates XHTML compliance (Wouter van Oijen / ProcoliX)
|
||||||
|
- fix: Splat_random Macro not so random (Wouter van Oijen / ProcoliX) (Thanks
|
||||||
|
to Colin Kuskie for pointing this out and writing some tests)
|
||||||
|
|
||||||
|
|
||||||
7.0.2
|
7.0.2
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,18 @@ versions. Be sure to heed the warnings contained herein as they will
|
||||||
save you many hours of grief.
|
save you many hours of grief.
|
||||||
|
|
||||||
|
|
||||||
|
7.0.3
|
||||||
|
--------------------------------------------------------------------
|
||||||
|
|
||||||
|
* Numbers generated by the Splat_random macro were not evenly
|
||||||
|
distributed. It returned numbers between 0 and 'max' (inclusive)
|
||||||
|
with this two numbers occuring about half as much as other numbers.
|
||||||
|
This is now fixed, so it will return numbers between 0 and 'max-1'
|
||||||
|
(inclusive), with an equal probability of any of these numbers.
|
||||||
|
If you're using this macro, you might need to increment the max
|
||||||
|
parameter.
|
||||||
|
|
||||||
|
|
||||||
7.0.2
|
7.0.2
|
||||||
--------------------------------------------------------------------
|
--------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,32 +21,30 @@ Package WebGUI::Macro::Splat_random
|
||||||
|
|
||||||
Macro for returning a bounded, integer random number.
|
Macro for returning a bounded, integer random number.
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 process ( max )
|
=head2 process ( max )
|
||||||
|
|
||||||
Random numbers are rounded, not truncated.
|
Random numbers are truncated to integer values.
|
||||||
|
|
||||||
=head3 max
|
=head3 max
|
||||||
|
|
||||||
The maximum random number. If omitted, 1_000_000_000 is
|
The upper bound for the random number. If omitted, 1_000_000_000 is
|
||||||
used as a default.
|
used as a default.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
|
||||||
sub process {
|
sub process {
|
||||||
my $session = shift;
|
my $session = shift;
|
||||||
my ($temp, @param, $limit);
|
my (@param, $limit);
|
||||||
@param = @_;
|
@param = @_;
|
||||||
if ($param[0] ne "") {
|
if ($param[0] ne "") {
|
||||||
$limit = $param[0];
|
$limit = $param[0];
|
||||||
} else {
|
} else {
|
||||||
$limit = 1000000000;
|
$limit = 1000000000;
|
||||||
}
|
}
|
||||||
$temp = round(rand($limit));
|
return int(rand($limit));
|
||||||
return $temp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
|
||||||
|
|
@ -71,9 +71,6 @@ WHOLE: for (my $i=0; $i<=999; $i++) {
|
||||||
++$bins[$output];
|
++$bins[$output];
|
||||||
}
|
}
|
||||||
|
|
||||||
is(scalar(@bins), 5, "All bins have values on a sample size of 1000");
|
is(scalar(@bins), 4, "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;
|
#diag Dumper \@bins;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue