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

Function main

examples/main.go:9–212  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7)
8
9func main() {
10
11 // d := stats.LoadRawData([]interface{}{1.1, "2", 3.0, 4, "5"})
12 d := stats.LoadRawData([]int{1, 2, 3, 4, 5})
13
14 a, _ := stats.Min(d)
15 fmt.Println(a)
16 // Output: 1.1
17
18 a, _ = stats.Max(d)
19 fmt.Println(a)
20 // Output: 5
21
22 a, _ = stats.Sum([]float64{1.1, 2.2, 3.3})
23 fmt.Println(a)
24 // Output: 6.6
25
26 cs, _ := stats.CumulativeSum([]float64{1.1, 2.2, 3.3})
27 fmt.Println(cs) // [1.1 3.3000000000000003 6.6]
28
29 a, _ = stats.Mean([]float64{1, 2, 3, 4, 5})
30 fmt.Println(a)
31 // Output: 3
32
33 a, _ = stats.Median([]float64{1, 2, 3, 4, 5, 6, 7})
34 fmt.Println(a)
35 // Output: 4
36
37 m, _ := stats.Mode([]float64{5, 5, 3, 3, 4, 2, 1})
38 fmt.Println(m)
39 // Output: [5 3]
40
41 a, _ = stats.PopulationVariance([]float64{1, 2, 3, 4, 5})
42 fmt.Println(a)
43 // Output: 2
44
45 a, _ = stats.SampleVariance([]float64{1, 2, 3, 4, 5})
46 fmt.Println(a)
47 // Output: 2.5
48
49 a, _ = stats.MedianAbsoluteDeviationPopulation([]float64{1, 2, 3})
50 fmt.Println(a)
51 // Output: 1
52
53 a, _ = stats.StandardDeviationPopulation([]float64{1, 2, 3})
54 fmt.Println(a)
55 // Output: 0.816496580927726
56
57 a, _ = stats.StandardDeviationSample([]float64{1, 2, 3})
58 fmt.Println(a)
59 // Output: 1
60
61 a, _ = stats.Percentile([]float64{1, 2, 3, 4, 5}, 75)
62 fmt.Println(a)
63 // Output: 4
64
65 a, _ = stats.PercentileNearestRank([]float64{35, 20, 15, 40, 50}, 75)
66 fmt.Println(a)

Callers

nothing calls this directly

Calls 15

LoadRawDataFunction · 0.92
MinFunction · 0.92
MaxFunction · 0.92
SumFunction · 0.92
CumulativeSumFunction · 0.92
MeanFunction · 0.92
MedianFunction · 0.92
ModeFunction · 0.92
PopulationVarianceFunction · 0.92
SampleVarianceFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…