Root/usrp/range

Source at commit 49e7c83796bc04941e9dbcec69bc0751563ff4d4 created 2 years 2 months ago.
By Werner Almesberger, atusb/: use ""VDD" symbol from kicad-libs
1#!/usr/bin/perl
2
3
4sub usage
5{
6    print STDERR "usage: $0 [[-v] tolerance]\n";
7    exit(1);
8}
9
10
11$tol = 999;
12
13if (@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
23while (<>) {
24    chop;
25    next if $_ eq "-inf";
26    push(@v, $_);
27    $s += $_;
28}
29$avg = $s/@v;
30
31$n = 0;
32for (@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
45if (!$ns) {
46    print STDERR "no samples\n";
47    exit(1);
48
49}
50
51print $sum/$ns, " $min $max\n";
52

Archive Download this file



interactive