Shrinkage

Gaussian

Gaussian fits a single real-valued response using averaged squared error:

F(y,η)=12n∑i=1n(yi−ηi)2,∇ηF=η−yn,∇η2F=1nI. F(y,\eta) = \frac{1}{2n}\sum_{i=1}^n(y_i - \eta_i)^2, \qquad \nabla_\eta F = \frac{\eta - y}{n},\qquad \nabla_\eta^2 F = \frac{1}{n}I.

Supply one finite response per observation. The constructor borrows the response slice. By default, the solver fits a free, unpenalized intercept; use .fit_intercept(false) to disable it. Predictions are fitted response means.

Evaluate the loss

use shrinkage::{Datafit, Gaussian};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let y = [1.0, 3.0];
    let datafit = Gaussian::new(&y);
    assert!((datafit.value(&[0.0, 2.0])? - 0.5).abs() < 1e-14);
    Ok(())
}

For model fitting, see linear regression or the Lasso convenience API. All four built-in solvers support Gaussian problems with their respective compatible penalties. Because the loss averages over observations, a penalty strength is not multiplied by the sample size. See the shared conventions.

The default identity link makes predictors equal response means. Use .with_link(...) to select a different Rust link for IRLS fitting and paths; convert predictions with .inverse_link(eta).

API: shrinkage::Gaussian.