feat: add Variance for math package

This commit is contained in:
dudaodong committed 2024-11-18 16:25:32 +08:00
1 parent ec161f335d
commit 6b2c91b0f6
5 files changed
+130

No files matched your search

+12
View File
@@ -478,3 +478,15 @@ func ExampleDiv() {
// 0.5
// 0
}
func ExampleVariance() {
result1 := Variance([]int{1, 2, 3, 4, 5})
result2 := Variance([]float64{1.1, 2.2, 3.3, 4.4, 5.5})
fmt.Println(result1)
fmt.Println(result2)
// Output:
// 2
// 2.42
}