import ( "math" "sort" "gonum.org/v1/gonum/stat" ) xs := []float64{ 32.32, 56.98, 21.52, 44.32, 55.63, 13.75, 43.47, 43.34, 12.34, } printf("data: %v\n", xs) // computes the weighted mean of the dataset. // we don't have any weights (ie: all weights are 1) // so we just pass a nil slice. mean := stat.Mean(xs, nil) variance := stat.Variance(xs, nil) stddev := math.Sqrt(variance) // stat.Quantile needs the input slice to be sorted. sort.Float64s(xs) printf("data: %v (sorted)\n", xs) // computes the median of the dataset. // here as well, we pass a nil slice as weights. median := stat.Quantile(0.5, stat.Empirical, xs, nil) printf("mean= %v\n", mean) printf("median= %v\n", median) printf("variance= %v\n", variance) printf("std-dev= %v\n", stddev)