pub struct GridSpline2dDesign { /* private fields */ }Expand description
Banded sufficient statistics of one streaming pass plus the exact penalty: everything needed to evaluate the REML criterion and solve at any λ.
Implementations§
Source§impl GridSpline2dDesign
impl GridSpline2dDesign
Sourcepub fn build(
x1: &[f64],
x2: &[f64],
y: &[f64],
w: &[f64],
k: usize,
metric: [f64; 2],
) -> Result<Self, String>
pub fn build( x1: &[f64], x2: &[f64], y: &[f64], w: &[f64], k: usize, metric: [f64; 2], ) -> Result<Self, String>
Single-response entry: see Self::build_multi.
Sourcepub fn build_multi(
x1: &[f64],
x2: &[f64],
responses: &[&[f64]],
w: &[f64],
k: usize,
metric: [f64; 2],
) -> Result<Self, String>
pub fn build_multi( x1: &[f64], x2: &[f64], responses: &[&[f64]], w: &[f64], k: usize, metric: [f64; 2], ) -> Result<Self, String>
One streaming pass over the rows plus the exact per-cell quadrature
assembly of the penalty. k is the number of cells per axis;
metric = [a1, a2] is the diagonal anisotropy of the biharmonic form.
responses holds one length-n response per dimension; the design,
penalty, and the REML-shared λ are common to all dimensions (one
surface smoothness), only the right-hand sides differ.
Sourcepub fn basis_per_axis(&self) -> usize
pub fn basis_per_axis(&self) -> usize
Basis functions per axis, K + 3.
Sourcepub fn num_coeffs(&self) -> usize
pub fn num_coeffs(&self) -> usize
Total coefficient count (K + 3)².
Sourcepub fn lower_corner(&self) -> [f64; 2]
pub fn lower_corner(&self) -> [f64; 2]
Lower corner of the data bounding box per axis.
Sourcepub fn cell_widths(&self) -> [f64; 2]
pub fn cell_widths(&self) -> [f64; 2]
Knot-cell width per axis.
Sourcepub fn num_responses(&self) -> usize
pub fn num_responses(&self) -> usize
Number of response dimensions sharing the design.
Sourcepub fn axis_basis(
&self,
axis: usize,
x: f64,
) -> Result<(usize, [f64; 4]), String>
pub fn axis_basis( &self, axis: usize, x: f64, ) -> Result<(usize, [f64; 4]), String>
The four active cubic B-spline values of one AXIS at x: returns
(j0, values) where values[i] weights basis j0 + i of that axis
(0..K+3). The tensor flat index of (j1, j2) is j1·(K+3) + j2 —
row-major, axis 0 major. Outside the bounding box the boundary cell’s
cubic polynomial extends (same convention as fitting and prediction).
Sourcepub fn penalty_value(&self, coeff: &[f64]) -> Result<f64, String>
pub fn penalty_value(&self, coeff: &[f64]) -> Result<f64, String>
Exact penalty quadratic form J(f) = c'Sc of a coefficient vector —
the assembled anisotropic biharmonic energy of the spline it encodes.
Sourcepub fn fit_at(
&self,
log_lambda: f64,
sigma2: Option<f64>,
) -> Result<GridSpline2dFit, String>
pub fn fit_at( &self, log_lambda: f64, sigma2: Option<f64>, ) -> Result<GridSpline2dFit, String>
Fit at a FIXED log λ, with σ² either supplied (applied to every
response dimension) or profiled per dimension.
Sourcepub fn fit_reml(&self) -> Result<GridSpline2dFit, String>
pub fn fit_reml(&self) -> Result<GridSpline2dFit, String>
Fit with log λ selected by the profiled REML criterion: deterministic
coarse grid then golden-section refinement (no RNG — same data, same fit).
Sourcepub fn posterior(
&self,
fit: &GridSpline2dFit,
) -> Result<GridSpline2dPosterior, String>
pub fn posterior( &self, fit: &GridSpline2dFit, ) -> Result<GridSpline2dPosterior, String>
Posterior summary of a fit FROM THIS DESIGN, in the exact algebra of the solved system (no approximation):
unit_covariance = (X'WX + λS)⁻¹(scale-free Bayesian posterior covariance of the row-major coefficient vec, shared by dimensions);edf = tr[(X'WX + λS)⁻¹ X'WX](the smoother’s effective degrees of freedom at the fitted λ);residual_cross_cov[d,e] = r_d'W r_e / (n − edf)assembled from the streamed sufficient statistics (y_d'Wy_e − c_d'X'Wy_e − c_e'X'Wy_d + c_d'X'WX c_e).
Auto Trait Implementations§
impl Freeze for GridSpline2dDesign
impl RefUnwindSafe for GridSpline2dDesign
impl Send for GridSpline2dDesign
impl Sync for GridSpline2dDesign
impl Unpin for GridSpline2dDesign
impl UnsafeUnpin for GridSpline2dDesign
impl UnwindSafe for GridSpline2dDesign
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T, U> Imply<T> for U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.