Enforce monotonicity of quantiles to fix crossing

enforce_monotonicity(quantiles, method = "sort", weights = NULL)

Arguments

quantiles

Tensor. Predicted quantiles that may have crossing violations. Shape: (*batch_shape, num_quantiles).

method

Character. Method for fixing crossing:

  • "sort": Sort values (fast, default)

  • "isotonic": Pool Adjacent Violators (optimal L2, O(N))

  • "cummax": Cumulative maximum (fast but distorts distribution)

weights

Tensor or NULL. Case weights for PAVA method. Shape: (*batch_shape, num_quantiles) or NULL.

Value

Tensor. Monotonically non-decreasing quantiles. Shape: (*batch_shape, num_quantiles).