Date:2011-10-11 14:23:37 (7 years 10 months ago)
Author:Werner Almesberger
Commit:ddd8338e251ed4c4a139c785e61418eceb901b5c
Message:m1rc3/norruption/2/plot: renamed to plot-cdf

Files: m1rc3/norruption/2/plot (1 diff)
m1rc3/norruption/2/plot-cdf (1 diff)

Change Details

m1rc3/norruption/2/plot
1#!/usr/bin/perl
2$n = 1;
3while (<>) {
4    next unless /^=== (\d+) ===/;
5    while ($1 != $n) {
6        push(@f, $n);
7        $n++;
8    }
9    $n++;
10}
11
12$n--;
13$f = int($n/@f+0.5);
14
15$last = 0;
16for (@f) {
17    push(@d, $_-$last);
18    $last = $_;
19}
20
21$cmd = "|gnuplot -e '".
22    'set term postscript color eps enhanced solid lw 2 20;'.
23    'set output "out.eps";'.
24    'set title "Probability distribution of time between NOR corruptions";'.
25    'set xlabel "Power cycles";'.
26    'set ylabel "Cumulative probability";'.
27    'set key bottom;'.
28    'plot "-" with steps title "Empirical distribution (N='.@f.')", '.
29      '1-exp(-'.1/$f.'*x) with lines lt 3 '.
30      'title "Exponential distribution ({/Symbol l}=1/'.$f.')"'.
31    "'";
32
33open(PIPE, $cmd) || die "open: $!";
34$i = 0;
35for (sort { $a <=> $b } @d) {
36    $i++;
37    print PIPE $_, " ", $i/@f, "\n";
38}
39close(PIPE) || die "close: $!";
40
41system("cat out.eps | ".
42    "gs -sDEVICE=ppmraw -r100 -sOutputFile=- ".
43    "-dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sPAPERSIZE=a4 -q - | ".
44    "convert -trim - out.png");
45unlink("out.eps");
m1rc3/norruption/2/plot-cdf
1#!/usr/bin/perl
2$n = 1;
3while (<>) {
4    next unless /^=== (\d+) ===/;
5    while ($1 != $n) {
6        push(@f, $n);
7        $n++;
8    }
9    $n++;
10}
11
12$n--;
13$f = int($n/@f+0.5);
14
15$last = 0;
16for (@f) {
17    push(@d, $_-$last);
18    $last = $_;
19}
20
21$cmd = "|gnuplot -e '".
22    'set term postscript color eps enhanced solid lw 2 20;'.
23    'set output "out.eps";'.
24    'set title "Probability distribution of time between NOR corruptions";'.
25    'set xlabel "Power cycles";'.
26    'set ylabel "Cumulative probability";'.
27    'set key bottom;'.
28    'plot "-" with steps title "Empirical distribution (N='.@f.')", '.
29      '1-exp(-'.1/$f.'*x) with lines lt 3 '.
30      'title "Exponential distribution ({/Symbol l}=1/'.$f.')"'.
31    "'";
32
33open(PIPE, $cmd) || die "open: $!";
34$i = 0;
35for (sort { $a <=> $b } @d) {
36    $i++;
37    print PIPE $_, " ", $i/@f, "\n";
38}
39close(PIPE) || die "close: $!";
40
41system("cat out.eps | ".
42    "gs -sDEVICE=ppmraw -r100 -sOutputFile=- ".
43    "-dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sPAPERSIZE=a4 -q - | ".
44    "convert -trim - out.png");
45unlink("out.eps");

Archive Download the corresponding diff file

Branches:
master



interactive