mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-11 16:22:26 +08:00
feat: add StdDev and fix bug of Average for math package
This commit is contained in:
@@ -178,7 +178,7 @@ func ExampleAverage() {
|
||||
fmt.Println(result2)
|
||||
|
||||
// Output:
|
||||
// 1
|
||||
// 1.5
|
||||
// 1.3
|
||||
}
|
||||
|
||||
@@ -490,3 +490,15 @@ func ExampleVariance() {
|
||||
// 2
|
||||
// 2.42
|
||||
}
|
||||
|
||||
func ExampleStdDev() {
|
||||
result1 := TruncRound(StdDev([]int{1, 2, 3, 4, 5}), 2)
|
||||
result2 := TruncRound(StdDev([]float64{1.1, 2.2, 3.3, 4.4, 5.5}), 2)
|
||||
|
||||
fmt.Println(result1)
|
||||
fmt.Println(result2)
|
||||
|
||||
// Output:
|
||||
// 1.41
|
||||
// 1.55
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user