pub trait VectorLikelihood {
// Required methods
fn log_lik(&self, eta: ArrayView2<'_, f64>, y: ArrayView2<'_, f64>) -> f64;
fn grad_eta(
&self,
eta: ArrayView2<'_, f64>,
y: ArrayView2<'_, f64>,
) -> Array2<f64>;
fn hess_diag(
&self,
eta: ArrayView2<'_, f64>,
y: ArrayView2<'_, f64>,
) -> Array2<f64>;
// Provided method
fn hess_block(
&self,
eta: ArrayView2<'_, f64>,
y: ArrayView2<'_, f64>,
) -> Array3<f64> { ... }
}Expand description
Connector trait the inner solver (Piece 1) plugs into.
eta is the (N, M) linear predictor; y is the (N, M) target. The
implementation is responsible for any link inversion. The hess_diag
return is the per-element diagonal of the per-row Hessian block; for a
Diagonal-noise Gaussian this is exactly (N, M) of per-output precisions.
Required Methods§
Sourcefn log_lik(&self, eta: ArrayView2<'_, f64>, y: ArrayView2<'_, f64>) -> f64
fn log_lik(&self, eta: ArrayView2<'_, f64>, y: ArrayView2<'_, f64>) -> f64
log p(Y | η).
Sourcefn grad_eta(
&self,
eta: ArrayView2<'_, f64>,
y: ArrayView2<'_, f64>,
) -> Array2<f64>
fn grad_eta( &self, eta: ArrayView2<'_, f64>, y: ArrayView2<'_, f64>, ) -> Array2<f64>
∂ log p(Y | η) / ∂ η, shape (N, M).
Sourcefn hess_diag(
&self,
eta: ArrayView2<'_, f64>,
y: ArrayView2<'_, f64>,
) -> Array2<f64>
fn hess_diag( &self, eta: ArrayView2<'_, f64>, y: ArrayView2<'_, f64>, ) -> Array2<f64>
Diagonal of the per-row Hessian −∂² log p / ∂ η ∂ η, shape (N, M).
This is the per-row block consumed by solver/arrow_schur.rs.
Provided Methods§
Sourcefn hess_block(
&self,
eta: ArrayView2<'_, f64>,
y: ArrayView2<'_, f64>,
) -> Array3<f64>
fn hess_block( &self, eta: ArrayView2<'_, f64>, y: ArrayView2<'_, f64>, ) -> Array3<f64>
Per-row dense Hessian block −∂² log p / ∂η_a ∂η_b, shape (N, M, M).
Default implementation lifts Self::hess_diag onto the per-row
diagonal, valid only when the per-row Hessian is genuinely diagonal
across outputs (e.g. Gaussian with Isotropic/Diagonal noise).
Likelihoods with off-diagonal output coupling must override this:
GaussianVectorLikelihood with a low-rank precision factor F
(block w·(diag(precision) + F·Fᵀ), off-diagonals w·Σ_k F[a,k]·F[b,k])
and multinomial-logit (per-row Fisher block p_a (δ_ab − p_b)).
The returned array is consumed by
gam_solve::pirls::dense_block_xtwx /
gam_solve::pirls::dense_block_xtwy to build XᵀWX and XᵀWy
for vector-response IRLS in output-major coefficient ordering.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".