2011-10-11 09:25:46 +03:00
|
|
|
#!/usr/bin/perl
|
|
|
|
$n = 1;
|
|
|
|
while (<>) {
|
|
|
|
next unless /^=== (\d+) ===/;
|
|
|
|
while ($1 != $n) {
|
|
|
|
push(@f, $n);
|
|
|
|
$n++;
|
|
|
|
}
|
|
|
|
$n++;
|
|
|
|
}
|
|
|
|
|
|
|
|
$n--;
|
|
|
|
$f = int($n/@f+0.5);
|
|
|
|
|
|
|
|
$last = 0;
|
|
|
|
for (@f) {
|
|
|
|
push(@d, $_-$last);
|
|
|
|
$last = $_;
|
|
|
|
}
|
|
|
|
|
|
|
|
$cmd = "|gnuplot -e '".
|
|
|
|
'set term postscript color eps enhanced solid lw 2 20;'.
|
|
|
|
'set output "out.eps";'.
|
|
|
|
'set title "Probability distribution of time between NOR corruptions";'.
|
|
|
|
'set xlabel "Power cycles";'.
|
|
|
|
'set ylabel "Cumulative probability";'.
|
|
|
|
'set key bottom;'.
|
2011-10-11 15:22:37 +03:00
|
|
|
'plot "-" with steps title "Empirical distribution (N='.@f.')", '.
|
2011-10-11 09:25:46 +03:00
|
|
|
'1-exp(-'.1/$f.'*x) with lines lt 3 '.
|
|
|
|
'title "Exponential distribution ({/Symbol l}=1/'.$f.')"'.
|
|
|
|
"'";
|
|
|
|
|
|
|
|
open(PIPE, $cmd) || die "open: $!";
|
|
|
|
$i = 0;
|
|
|
|
for (sort { $a <=> $b } @d) {
|
|
|
|
$i++;
|
|
|
|
print PIPE $_, " ", $i/@f, "\n";
|
|
|
|
}
|
|
|
|
close(PIPE) || die "close: $!";
|
|
|
|
|
|
|
|
system("cat out.eps | ".
|
|
|
|
"gs -sDEVICE=ppmraw -r100 -sOutputFile=- ".
|
|
|
|
"-dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sPAPERSIZE=a4 -q - | ".
|
|
|
|
"convert -trim - out.png");
|
|
|
|
unlink("out.eps");
|