IEEE 802.15.4 subsystem
Sign in or create your account | Project List | Help
IEEE 802.15.4 subsystem Git Source Tree
Root/
1 | #!/usr/bin/perl |
2 | |
3 | |
4 | sub usage |
5 | { |
6 | print STDERR "usage: $0 [[-v] tolerance]\n"; |
7 | exit(1); |
8 | } |
9 | |
10 | |
11 | $tol = 999; |
12 | |
13 | if (@ARGV) { |
14 | $tol = shift @ARGV; |
15 | if ($tol eq "-v") { |
16 | $verbose = 1; |
17 | $tol = shift @ARGV; |
18 | } |
19 | &usage unless $tol =~ /^[0-9.]+$/; |
20 | &usage if @ARGV; |
21 | } |
22 | |
23 | while (<>) { |
24 | chop; |
25 | next if $_ eq "-inf"; |
26 | push(@v, $_); |
27 | $s += $_; |
28 | } |
29 | $avg = $s/@v; |
30 | |
31 | $n = 0; |
32 | for (@v) { |
33 | $n++; |
34 | next if $_ eq "-inf"; |
35 | if ($_ < $avg-$tol || $_ > $avg+$tol) { |
36 | print STDERR "sample $n is outlier ($avg): $_\n" if $verbose; |
37 | next; |
38 | } |
39 | $sum += $_; |
40 | $ns++; |
41 | $min = $_ if $_ < $min || !defined $min; |
42 | $max = $_ if $_ > $max || !defined $max; |
43 | } |
44 | |
45 | if (!$ns) { |
46 | print STDERR "no samples\n"; |
47 | exit(1); |
48 | |
49 | } |
50 | |
51 | print $sum/$ns, " $min $max\n"; |
52 |