pub fn compute_lambda_max(
x: &Matrix,
y: &[f64],
alpha: f64,
penalty_factor: Option<&[f64]>,
intercept_col: Option<usize>,
) -> f64Expand description
Computes lambda_max: the smallest lambda for which all penalized coefficients are zero.
For lasso (alpha > 0), lambda_max is the smallest value such that the soft-thresholding operation zeros out all coefficients.
For standardized X and centered y:
lambda_max = max_j |x_j^T y| / (n * alpha)§Arguments
x- Standardized design matrix (n × p), first column is intercept if presenty- Centered response vector (n elements)alpha- Elastic net mixing parameterpenalty_factor- Per-feature penalty factors (optional, defaults to all 1.0)intercept_col- Index of intercept column (typically 0, or None if no intercept)
§Returns
The maximum lambda value for the path.
§Note
If alpha = 0 (pure ridge), this returns f64::INFINITY since ridge never produces
exact zero coefficients. Use make_lambda_path which handles this case by using
a small alpha value.