Data Science, Computer Science, Python, Probability, Machine Learning.
everything together: func Choice[T any]( arr []T, size int, replace bool, probs []float64, rng *rand.Rand, ) ([]T, error) { if !replace && (size > len(arr)) { return nil, errors.New("cannot sample more than array size without replacements") } samples := make([]T, size) probsCopy := make([]float64,