first trial of obilandmark

Former-commit-id: 00a50bdbf407b03dfdc385a848a536559f5966a5
This commit is contained in:
2023-08-25 23:23:23 +02:00
parent 2a11adb346
commit 077f3b5bb5
5 changed files with 388 additions and 0 deletions

25
pkg/obistats/random.go Normal file
View File

@ -0,0 +1,25 @@
package obistats
import "math/rand"
func SampleIntWithoutReplacemant(n, max int) []int {
draw := make(map[int]int, n)
for i := 0; i < n; i++ {
y := rand.Intn(max)
x, ok := draw[y]
if ok {
y = x
}
draw[y] = max - 1
max--
}
res := make([]int, 0, n)
for i := range draw {
res = append(res, i)
}
return res
}