package datascience

// Clip recorta cada valor del slice para que quede dentro del rango [min, max].
func Clip(data []float64, min, max float64) []float64 {
	result := make([]float64, len(data))
	for i, v := range data {
		switch {
		case v < min:
			result[i] = min
		case v > max:
			result[i] = max
		default:
			result[i] = v
		}
	}
	return result
}
