r66784 - in /branches/upstream/libstatistics-test-randomwalk-perl/current: Changes MANIFEST META.yml Makefile.PL README examples/comparison_integer.pl lib/Statistics/Test/RandomWalk.pm
jawnsy-guest at users.alioth.debian.org
jawnsy-guest at users.alioth.debian.org
Sat Jan 1 15:39:37 UTC 2011
Author: jawnsy-guest
Date: Sat Jan 1 15:39:24 2011
New Revision: 66784
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=66784
Log:
[svn-upgrade] new version libstatistics-test-randomwalk-perl (0.02)
Added:
branches/upstream/libstatistics-test-randomwalk-perl/current/examples/comparison_integer.pl
Modified:
branches/upstream/libstatistics-test-randomwalk-perl/current/Changes
branches/upstream/libstatistics-test-randomwalk-perl/current/MANIFEST
branches/upstream/libstatistics-test-randomwalk-perl/current/META.yml
branches/upstream/libstatistics-test-randomwalk-perl/current/Makefile.PL
branches/upstream/libstatistics-test-randomwalk-perl/current/README
branches/upstream/libstatistics-test-randomwalk-perl/current/lib/Statistics/Test/RandomWalk.pm
Modified: branches/upstream/libstatistics-test-randomwalk-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libstatistics-test-randomwalk-perl/current/Changes?rev=66784&op=diff
==============================================================================
--- branches/upstream/libstatistics-test-randomwalk-perl/current/Changes (original)
+++ branches/upstream/libstatistics-test-randomwalk-perl/current/Changes Sat Jan 1 15:39:24 2011
@@ -1,5 +1,8 @@
Revision history for Perl extension Statistics::Test::RandomWalk
+0.02 Fri Dec 31 19:00 2010
+ - Example for testing an integer RNG
+ - Add rescaling factor
+
0.01 Sat Jan 6 18:33 2007
- - original version
-
+ - original version
Modified: branches/upstream/libstatistics-test-randomwalk-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libstatistics-test-randomwalk-perl/current/MANIFEST?rev=66784&op=diff
==============================================================================
--- branches/upstream/libstatistics-test-randomwalk-perl/current/MANIFEST (original)
+++ branches/upstream/libstatistics-test-randomwalk-perl/current/MANIFEST Sat Jan 1 15:39:24 2011
@@ -1,5 +1,6 @@
Changes
examples/comparison.pl
+examples/comparison_integer.pl
lib/Statistics/Test/RandomWalk.pm
Makefile.PL
MANIFEST This list of files
Modified: branches/upstream/libstatistics-test-randomwalk-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libstatistics-test-randomwalk-perl/current/META.yml?rev=66784&op=diff
==============================================================================
--- branches/upstream/libstatistics-test-randomwalk-perl/current/META.yml (original)
+++ branches/upstream/libstatistics-test-randomwalk-perl/current/META.yml Sat Jan 1 15:39:24 2011
@@ -1,16 +1,25 @@
--- #YAML:1.0
-name: Statistics-Test-RandomWalk
-version: 0.01
-abstract: Random Walk test for random numbers
-license: perl
-generated_by: ExtUtils::MakeMaker version 6.31
-distribution_type: module
-requires:
- Math::BigFloat: 0
- Params::Util: 0
- Statistics::Test::Sequence: 0
-meta-spec:
- url: http://module-build.sourceforge.net/META-spec-v1.2.html
- version: 1.2
+name: Statistics-Test-RandomWalk
+version: 0.02
+abstract: Random Walk test for random numbers
author:
- Steffen Mueller <smueller at cpan.org>
+license: perl
+distribution_type: module
+configure_requires:
+ ExtUtils::MakeMaker: 0
+build_requires:
+ ExtUtils::MakeMaker: 0
+requires:
+ Class::XSAccessor: 1.05
+ Math::BigFloat: 0
+ Params::Util: 0
+ Statistics::Test::Sequence: 0
+no_index:
+ directory:
+ - t
+ - inc
+generated_by: ExtUtils::MakeMaker version 6.55_02
+meta-spec:
+ url: http://module-build.sourceforge.net/META-spec-v1.4.html
+ version: 1.4
Modified: branches/upstream/libstatistics-test-randomwalk-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libstatistics-test-randomwalk-perl/current/Makefile.PL?rev=66784&op=diff
==============================================================================
--- branches/upstream/libstatistics-test-randomwalk-perl/current/Makefile.PL (original)
+++ branches/upstream/libstatistics-test-randomwalk-perl/current/Makefile.PL Sat Jan 1 15:39:24 2011
@@ -10,6 +10,7 @@
Params::Util => '0',
Math::BigFloat => '0',
Statistics::Test::Sequence => '0',
+ Class::XSAccessor => '1.05',
}, # e.g., Module::Name => 1.1
($] >= 5.005 ? ## Add these new keywords supported since 5.005
(ABSTRACT_FROM => 'lib/Statistics/Test/RandomWalk.pm', # retrieve abstract from module
Modified: branches/upstream/libstatistics-test-randomwalk-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libstatistics-test-randomwalk-perl/current/README?rev=66784&op=diff
==============================================================================
--- branches/upstream/libstatistics-test-randomwalk-perl/current/README (original)
+++ branches/upstream/libstatistics-test-randomwalk-perl/current/README Sat Jan 1 15:39:24 2011
@@ -23,6 +23,13 @@
METHODS
new
Creates a new random number tester.
+
+ set_rescale_factor
+ The default range of the random numbers [0, 1) can be rescaled by a
+ constant factor. This method is the setter for that factor.
+
+ rescale_factor
+ Returns the current rescaling factor.
set_data
Sets the random numbers to operate on. First argument must be either an
@@ -84,7 +91,7 @@
Steffen Mueller, <smueller at cpan.org>
COPYRIGHT AND LICENSE
- Copyright (C) 2007 by Steffen Mueller
+ Copyright (C) 2007-2010 by Steffen Mueller
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself, either Perl version 5.6 or, at your
Added: branches/upstream/libstatistics-test-randomwalk-perl/current/examples/comparison_integer.pl
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libstatistics-test-randomwalk-perl/current/examples/comparison_integer.pl?rev=66784&op=file
==============================================================================
--- branches/upstream/libstatistics-test-randomwalk-perl/current/examples/comparison_integer.pl (added)
+++ branches/upstream/libstatistics-test-randomwalk-perl/current/examples/comparison_integer.pl Sat Jan 1 15:39:24 2011
@@ -1,0 +1,36 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use lib 'lib';
+use Statistics::Test::RandomWalk;
+use Data::Dumper;
+use Math::Random::MT;
+my $t = Statistics::Test::RandomWalk->new();
+
+# If you have rng's that provide an integer in the range [0, $nmax),
+# then this is how you can test them:
+
+my $rnd;
+open my $fh, '<', '/dev/urandom' or die $!;
+read($fh, $rnd, 32);
+$rnd = unpack('%L', $rnd);
+my $gen = Math::Random::MT->new($rnd);
+
+my $nmax = 13; # the maximum integer returned
+$t->set_rescale_factor($nmax);
+my $num = 20000;
+foreach (
+ [ 'rand', sub {map int($nmax*rand()), 1..10000}, int($num/10000)+1 ],
+ [ 'MT', sub {map int($nmax*$gen->rand()), 1..10000}, int($num/10000)+1 ],
+) {
+ my $name = shift @$_;
+ $t->set_data(@$_);
+ print "Testing $name...\n";
+ # If $nmax is too large for your convenience, you can
+ # instead test $nmax/$something.
+ # (the result of which needs to be an integer...)
+ my ($alpha, $got, $expected) = $t->test($nmax);
+
+ print $t->data_to_report($alpha, $got, $expected);
+}
+
Modified: branches/upstream/libstatistics-test-randomwalk-perl/current/lib/Statistics/Test/RandomWalk.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libstatistics-test-randomwalk-perl/current/lib/Statistics/Test/RandomWalk.pm?rev=66784&op=diff
==============================================================================
--- branches/upstream/libstatistics-test-randomwalk-perl/current/lib/Statistics/Test/RandomWalk.pm (original)
+++ branches/upstream/libstatistics-test-randomwalk-perl/current/lib/Statistics/Test/RandomWalk.pm Sat Jan 1 15:39:24 2011
@@ -4,13 +4,22 @@
use strict;
use warnings;
-our $VERSION = '0.01';
+our $VERSION = '0.02';
use Carp qw/croak/;
use Params::Util qw/_POSINT _ARRAY _CODE/;
use Memoize;
use Math::BigFloat;
use Statistics::Test::Sequence;
+use Class::XSAccessor {
+ constructor => 'new',
+ getters => {
+ rescale_factor => 'rescale',
+ },
+ setters => {
+ set_rescale_factor => 'rescale',
+ },
+};
=head1 NAME
@@ -39,26 +48,18 @@
=head1 METHODS
-=cut
-
=head2 new
Creates a new random number tester.
-=cut
-
-sub new {
- my $proto = shift;
- my $class = ref($proto)||$proto;
-
- my $self = {
- data => undef,
- };
-
- bless $self => $class;
-
- return $self;
-}
+=head2 set_rescale_factor
+
+The default range of the random numbers [0, 1) can be rescaled
+by a constant factor. This method is the setter for that factor.
+
+=head2 rescale_factor
+
+Returns the current rescaling factor.
=head2 set_data
@@ -125,6 +126,7 @@
if (not _POSINT($bins)) {
croak("Expecting number of bins as argument to 'test'");
}
+ my $rescale_factor = $self->rescale_factor||1;
my $data = $self->{data};
@@ -133,7 +135,7 @@
croak("Set data using 'set_data' first.");
}
- my $step = 1 / $bins;
+ my $step = 1 / $bins * $rescale_factor;
my @alpha;
push @alpha, $_*$step for 1..$bins;
@@ -171,10 +173,10 @@
}
}
- my @expected_smaller = map Math::BigFloat->new($numbers)*$_, @alpha;
+ my @expected_smaller = map Math::BigFloat->new($numbers)*$_/$rescale_factor, @alpha;
return(
- \@alpha,
+ [map $_/$rescale_factor, @alpha],
\@bins,
\@expected_smaller,
);
@@ -285,7 +287,7 @@
=head1 COPYRIGHT AND LICENSE
-Copyright (C) 2007 by Steffen Mueller
+Copyright (C) 2007-2010 by Steffen Mueller
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.6 or,
More information about the Pkg-perl-cvs-commits
mailing list