MCPcopy
hub / github.com/montanaflynn/stats / Min

Function Min

min.go:6–26  ·  view source on GitHub ↗

Min finds the lowest number in a set of data

(input Float64Data)

Source from the content-addressed store, hash-verified

4
5// Min finds the lowest number in a set of data
6func Min(input Float64Data) (min float64, err error) {
7
8 // Get the count of numbers in the slice
9 l := input.Len()
10
11 // Return an error if there are no numbers
12 if l == 0 {
13 return math.NaN(), EmptyInputErr
14 }
15
16 // Get the first value as the starting point
17 min = input.Get(0)
18
19 // Iterate until done checking for a lower value
20 for i := 1; i < l; i++ {
21 if input.Get(i) < min {
22 min = input.Get(i)
23 }
24 }
25 return min, nil
26}

Callers 11

ExampleMinFunction · 0.92
TestMinFunction · 0.92
TestDescribeValuesFunction · 0.92
BenchmarkRegularAPIFunction · 0.92
mainFunction · 0.92
DescribePercentileFuncFunction · 0.85
MinMethod · 0.85

Calls 2

LenMethod · 0.80
GetMethod · 0.80

Tested by 8

ExampleMinFunction · 0.74
TestMinFunction · 0.74
TestDescribeValuesFunction · 0.74
BenchmarkRegularAPIFunction · 0.74