kumulant

Link

@Serializable
sealed interface Link(source)

Canonical GLM link function. Encodes everything that varies between Gaussian linear regression and its GLM siblings:

  • invMean turns the linear predictor eta = bias + x . w into the response mean (identity / sigmoid / exp).

  • curvature is the second derivative of the per-observation negative log-likelihood w.r.t. eta, used by DiagonalRegressionStat / BayesianRegressionStat to tighten precision per observation. Equals the variance function under the canonical link.

  • loss is the per-observation negative log-likelihood computed in a numerically stable way (log-trick for Logit, no overflow on either tail). Constants that don't depend on eta are dropped, so the absolute value is shifted but differences and sums are correct.

Only canonical links are exposed: pairing a non-canonical link with the gradient shortcut grad_i = (mu - y) * x_i is wrong, so restricting the type rules that out.

Inheritors

Types

Link copied to clipboard
@Serializable
@SerialName(value = "Identity")
data object Identity : Link

mu = eta. Gaussian likelihood with sigma^2 = 1.

Link copied to clipboard
@Serializable
@SerialName(value = "Log")
data object Log : Link

mu = exp(eta). Poisson likelihood; expects y >= 0.

Link copied to clipboard
@Serializable
@SerialName(value = "Logit")
data object Logit : Link

mu = sigmoid(eta). Bernoulli likelihood; expects y in {0, 1}.

Functions

Link copied to clipboard
abstract fun curvature(eta: Double): Double

Second derivative of the per-observation negative log-likelihood at eta.

Link copied to clipboard
abstract fun invMean(eta: Double): Double

Inverse link: maps the linear predictor eta to the response mean.

Link copied to clipboard
abstract fun loss(eta: Double, y: Double): Double

Per-observation negative log-likelihood (modulo eta-independent constants).

curvature

abstract fun curvature(eta: Double): Double(source)

Second derivative of the per-observation negative log-likelihood at eta.

invMean

abstract fun invMean(eta: Double): Double(source)

Inverse link: maps the linear predictor eta to the response mean.

loss

abstract fun loss(eta: Double, y: Double): Double(source)

Per-observation negative log-likelihood (modulo eta-independent constants).