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

Function TestMedianAbsoluteDeviationPopulation

deviation_test.go:17–40  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

15}
16
17func TestMedianAbsoluteDeviationPopulation(t *testing.T) {
18 s, _ := stats.MedianAbsoluteDeviation([]float64{1, 2, 3})
19 m, err := stats.Round(s, 2)
20 if err != nil {
21 t.Errorf("Returned an error")
22 }
23 if m != 1.00 {
24 t.Errorf("%.10f != %.10f", m, 1.00)
25 }
26
27 s, _ = stats.MedianAbsoluteDeviation([]float64{-2, 0, 4, 5, 7})
28 m, err = stats.Round(s, 2)
29 if err != nil {
30 t.Errorf("Returned an error")
31 }
32 if m != 3.00 {
33 t.Errorf("%.10f != %.10f", m, 3.00)
34 }
35
36 m, _ = stats.MedianAbsoluteDeviation([]float64{})
37 if !math.IsNaN(m) {
38 t.Errorf("%.1f != %.1f", m, math.NaN())
39 }
40}
41
42func TestStandardDeviation(t *testing.T) {
43 _, err := stats.StandardDeviation([]float64{1, 2, 3})

Callers

nothing calls this directly

Calls 2

MedianAbsoluteDeviationFunction · 0.92
RoundFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…