-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
76 lines (61 loc) · 1.91 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package main
// purpose:
// init flags
// read ints from stdin
// sort ints[]
// calc quartile
// print deviant values with adaptable Tukey value
// or 3xMedian if -M is choosed
// v0.1 print green/red values
// v0.2 - dont mess original data, return 1 if found quartile deviance
// v0.3 - trim space and tabs
// v0.4 - float32 and direct input of "sort |uniq -c|sort -rn|head -nn"
// V0.5 - Adding Z-score mod méthod.
// V0.6 - Bug in getNumbers
import (
"flag"
"fmt"
"os"
)
var (
quietmode, printall, printquartile, printlimits bool
useMedianlimit, useBoxplot, useZScore, useZScoreMAD bool
// printlow, printupper bool
devianceFactor, ZdevianceFactor, minimalValue float64
// Version is git tag
Version string
)
func main() {
initflags()
data := readAll()
switch {
case useZScore:
os.Exit(ZScorePrintF32bis(data))
case useZScoreMAD:
os.Exit(ZScoreMADPrintF32bis(data))
default:
N := getNumbers(data, minimalValue)
Q := quartileCalcf32(N)
if Q[0] == 0 && Q[1] == 0 {
fmt.Printf("Bad quartile (Exiting) : \n")
printQuartile(Q)
os.Exit(-1)
}
os.Exit(quartileDeviantPrintf32(Q, data, minimalValue))
}
}
func initflags() {
flag.BoolVar(&quietmode, "q", false, "quiet mode")
flag.BoolVar(&printall, "a", false, "print all values")
flag.BoolVar(&printquartile, "Q", false, "print quartiles values")
flag.BoolVar(&printlimits, "l", false, "print limits")
flag.Float64Var(&devianceFactor, "f", 1.5, "Tukey deviance factor")
flag.Float64Var(&ZdevianceFactor, "z", 3.0, "Z Score deviance factor")
flag.Float64Var(&minimalValue, "m", 0, "minimal value")
flag.BoolVar(&useMedianlimit, "M", false, "use Median Limit instead (3x)")
flag.BoolVar(&useBoxplot, "B", false, "use Boxplot [M-(Q3-Q1),M+(Q3-Q1)]")
flag.BoolVar(&useZScore, "Z", false, "use Z-Score")
flag.BoolVar(&useZScoreMAD, "D", false, "use Z-Score mod")
flag.StringVar(&Version, "v", Version, "show current Version")
flag.Parse()
}