mirror of
git://projects.qi-hardware.com/wernermisc.git
synced 2024-11-15 11:50:37 +02:00
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.
This commit is contained in:
parent
1c331b3b5c
commit
36b52a976d
@ -2,34 +2,45 @@
|
||||
|
||||
sub usage
|
||||
{
|
||||
print STDERR "usage: $0 [-s] [log_file]\n";
|
||||
print STDERR "usage: $0 [-s [-n samples] [-i interval]] [log_file]\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
if ($ARGV[0] eq "-s") {
|
||||
shift @ARGV;
|
||||
$sim = 1;
|
||||
while ($ARGV[0] =~ /^-/) {
|
||||
$opt = shift @ARGV;
|
||||
if ($opt eq "-s") {
|
||||
$sim = 1;
|
||||
} elsif ($opt eq "-n") {
|
||||
$sim_n = shift @ARGV;
|
||||
&usage unless defined $sim_n;
|
||||
} elsif ($opt eq "-i") {
|
||||
$sim_t = shift @ARGV;
|
||||
&usage unless defined $sim_t;
|
||||
} else {
|
||||
&usage;
|
||||
}
|
||||
}
|
||||
&usage if $ARGV[0] =~ /^-/;
|
||||
|
||||
$n = 1;
|
||||
while (<>) {
|
||||
next unless /^=== (\d+) ===/;
|
||||
while ($1 != $n) {
|
||||
push(@f, $n);
|
||||
unless ($sim && defined $sim_n && defined $sim_t) {
|
||||
$n = 1;
|
||||
while (<>) {
|
||||
next unless /^=== (\d+) ===/;
|
||||
while ($1 != $n) {
|
||||
push(@f, $n);
|
||||
$n++;
|
||||
}
|
||||
$n++;
|
||||
}
|
||||
$n++;
|
||||
}
|
||||
|
||||
$n--;
|
||||
$t = int($n/@f+0.5);
|
||||
$n--;
|
||||
$t = int($n/@f+0.5);
|
||||
|
||||
$last = 0;
|
||||
for (@f) {
|
||||
push(@d, $_-$last);
|
||||
$last = $_;
|
||||
$last = 0;
|
||||
for (@f) {
|
||||
push(@d, $_-$last);
|
||||
$last = $_;
|
||||
}
|
||||
}
|
||||
|
||||
if ($sim) {
|
||||
@ -39,9 +50,11 @@ if ($sim) {
|
||||
# -T*ln(1-y) = x
|
||||
|
||||
$type = " (SIMULATED)";
|
||||
$sim_n = @f unless defined $sim_n;
|
||||
$sim_t = $t unless defined $sim_t;
|
||||
@d = ();
|
||||
for ($i = 0; $i != @f; $i++) {
|
||||
push(@d, -$t*log(1-rand));
|
||||
for ($i = 0; $i != $sim_n; $i++) {
|
||||
push(@d, -$sim_t*log(1-rand));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user