Date:2011-10-12 14:49:28 (7 years 8 months ago)
Author:Werner Almesberger
Commit:36b52a976d287876f06a12bdf34dfe13c80d7df0
Message:m1rc3/norruption/2/plot-corr: options -n and -i to set samples and interval

Simulation with both -n and -i also doesn't need to read a log file.
Files: m1rc3/norruption/2/plot-corr (2 diffs)

Change Details

m1rc3/norruption/2/plot-corr
22
33sub usage
44{
5    print STDERR "usage: $0 [-s] [log_file]\n";
5    print STDERR "usage: $0 [-s [-n samples] [-i interval]] [log_file]\n";
66    exit(1);
77}
88
99
10if ($ARGV[0] eq "-s") {
11    shift @ARGV;
12    $sim = 1;
10while ($ARGV[0] =~ /^-/) {
11    $opt = shift @ARGV;
12    if ($opt eq "-s") {
13        $sim = 1;
14    } elsif ($opt eq "-n") {
15        $sim_n = shift @ARGV;
16        &usage unless defined $sim_n;
17    } elsif ($opt eq "-i") {
18        $sim_t = shift @ARGV;
19        &usage unless defined $sim_t;
20    } else {
21        &usage;
22    }
1323}
14&usage if $ARGV[0] =~ /^-/;
1524
16$n = 1;
17while (<>) {
18    next unless /^=== (\d+) ===/;
19    while ($1 != $n) {
20        push(@f, $n);
25unless ($sim && defined $sim_n && defined $sim_t) {
26    $n = 1;
27    while (<>) {
28        next unless /^=== (\d+) ===/;
29        while ($1 != $n) {
30            push(@f, $n);
31            $n++;
32        }
2133        $n++;
2234    }
23    $n++;
24}
2535
26$n--;
27$t = int($n/@f+0.5);
36    $n--;
37    $t = int($n/@f+0.5);
2838
29$last = 0;
30for (@f) {
31    push(@d, $_-$last);
32    $last = $_;
39    $last = 0;
40    for (@f) {
41        push(@d, $_-$last);
42        $last = $_;
43    }
3344}
3445
3546if ($sim) {
...... 
3950    # -T*ln(1-y) = x
4051
4152    $type = " (SIMULATED)";
53    $sim_n = @f unless defined $sim_n;
54    $sim_t = $t unless defined $sim_t;
4255    @d = ();
43    for ($i = 0; $i != @f; $i++) {
44        push(@d, -$t*log(1-rand));
56    for ($i = 0; $i != $sim_n; $i++) {
57        push(@d, -$sim_t*log(1-rand));
4558    }
4659}
4760

Archive Download the corresponding diff file

Branches:
master



interactive