mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-06-29 16:20:46 +00:00
first trial of obilandmark
Former-commit-id: 00a50bdbf407b03dfdc385a848a536559f5966a5
This commit is contained in:
25
pkg/obistats/random.go
Normal file
25
pkg/obistats/random.go
Normal 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
|
||||
}
|
Reference in New Issue
Block a user