File: comparison.pl

package info (click to toggle)
libstatistics-test-sequence-perl 0.01-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 108 kB
  • sloc: perl: 170; makefile: 2
file content (42 lines) | stat: -rw-r--r-- 864 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/perl
use strict;
use warnings;
use lib 'lib';
use Statistics::Test::Sequence;
use Data::Dumper;
use Math::Random::MT;
my $t = Statistics::Test::Sequence->new();

my $rnd;
open my $fh, '<', '/dev/random' or die $!;
read($fh, $rnd, 32);
$rnd = unpack('%L', $rnd);
my $gen = Math::Random::MT->new($rnd);

{
    my $x = 4711;
    my $a = 421;
    my $c = 64773;
    my $m = 259200;
    sub lin_kong {
        $x = ($a*$x + $c) % $m;
        return $x;
    }
}

my $num = 10000000;
foreach (
    [ 'rand', sub {map rand(), 1..10000}, $num/10000 ],
    [ 'MT',   sub {map $gen->rand(), 1..10000}, $num/10000 ],
    [ 'lin',  \&lin_kong, $num ],
) {
    my $name = shift @$_;
    $t->set_data(@$_);
    print "Testing $name...\n";
    my ($resid, $bins, $expected) = $t->test();
    print Dumper $resid;
    print Dumper $bins;
    print Dumper $expected;
}