mirror of
git://projects.qi-hardware.com/wernermisc.git
synced 2024-11-15 13:56:22 +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,17 +2,27 @@
|
|||||||
|
|
||||||
sub usage
|
sub usage
|
||||||
{
|
{
|
||||||
print STDERR "usage: $0 [-s] [log_file]\n";
|
print STDERR "usage: $0 [-s [-n samples] [-i interval]] [log_file]\n";
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($ARGV[0] eq "-s") {
|
while ($ARGV[0] =~ /^-/) {
|
||||||
shift @ARGV;
|
$opt = shift @ARGV;
|
||||||
|
if ($opt eq "-s") {
|
||||||
$sim = 1;
|
$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] =~ /^-/;
|
|
||||||
|
|
||||||
|
unless ($sim && defined $sim_n && defined $sim_t) {
|
||||||
$n = 1;
|
$n = 1;
|
||||||
while (<>) {
|
while (<>) {
|
||||||
next unless /^=== (\d+) ===/;
|
next unless /^=== (\d+) ===/;
|
||||||
@ -31,6 +41,7 @@ for (@f) {
|
|||||||
push(@d, $_-$last);
|
push(@d, $_-$last);
|
||||||
$last = $_;
|
$last = $_;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($sim) {
|
if ($sim) {
|
||||||
# y = 1-exp(-x/T)
|
# y = 1-exp(-x/T)
|
||||||
@ -39,9 +50,11 @@ if ($sim) {
|
|||||||
# -T*ln(1-y) = x
|
# -T*ln(1-y) = x
|
||||||
|
|
||||||
$type = " (SIMULATED)";
|
$type = " (SIMULATED)";
|
||||||
|
$sim_n = @f unless defined $sim_n;
|
||||||
|
$sim_t = $t unless defined $sim_t;
|
||||||
@d = ();
|
@d = ();
|
||||||
for ($i = 0; $i != @f; $i++) {
|
for ($i = 0; $i != $sim_n; $i++) {
|
||||||
push(@d, -$t*log(1-rand));
|
push(@d, -$sim_t*log(1-rand));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user