INNER CODE UNIT · Go
StdDev
deepfence/FlowMeter · pkg/common/common.go:99
func StdDev(array []int) float64 {
if len(array) == 0 {
return 0.0
} else {
square := float64(0)
for _, v := range array {
square += (float64(v) - Mean(array)) * (float64(v) - Mean(array))
}
return math.Sqrt(square / float64(len(array)))
}
}
// Takes a slice and looks for an element in it. If found it will
// return it's key, otherwise it will return -1 and a bool of false.
func IfPresentInSlice(slice []int, val int) (int, bool) {
for i, item := range slice {