pub struct OrdinaryKriging { /* private fields */ }Expand description
Ordinary Kriging interpolator
Ordinary Kriging assumes the mean is unknown but constant within a local neighborhood. It provides the Best Linear Unbiased Estimator (BLUE) for spatial data.
Implementations§
Source§impl OrdinaryKriging
impl OrdinaryKriging
Sourcepub fn new(
points: &ArrayView2<'_, f64>,
values: &ArrayView1<'_, f64>,
variogram: VariogramModel,
) -> SpatialResult<Self>
pub fn new( points: &ArrayView2<'_, f64>, values: &ArrayView1<'_, f64>, variogram: VariogramModel, ) -> SpatialResult<Self>
Create a new Ordinary Kriging interpolator
§Arguments
points- Array of point coordinates, shape (n_points, ndim)values- Array of values at points, shape (n_points,)variogram- Variogram model to use
§Returns
- New OrdinaryKriging instance
§Examples
use scirs2_spatial::kriging::{OrdinaryKriging, VariogramModel};
use ndarray::array;
let points = array![[0.0, 0.0], [1.0, 0.0], [0.0, 1.0]];
let values = array![1.0, 2.0, 3.0];
let variogram = VariogramModel::spherical(1.0, 0.5, 0.1);
let kriging = OrdinaryKriging::new(&points.view(), &values.view(), variogram).unwrap();Sourcepub fn fit(&mut self) -> SpatialResult<()>
pub fn fit(&mut self) -> SpatialResult<()>
Fit the Kriging model by precomputing the covariance matrix inverse
This step is optional but recommended for multiple predictions as it avoids recomputing the matrix inverse each time.
Sourcepub fn predict(&self, location: &[f64]) -> SpatialResult<KrigingPrediction>
pub fn predict(&self, location: &[f64]) -> SpatialResult<KrigingPrediction>
Predict value at a new location
§Arguments
location- Point where to predict, shape (ndim,)
§Returns
- KrigingPrediction with value, variance, and weights
§Examples
use scirs2_spatial::kriging::{OrdinaryKriging, VariogramModel};
use ndarray::array;
let points = array![[0.0, 0.0], [1.0, 0.0], [0.0, 1.0], [1.0, 1.0]];
let values = array![1.0, 2.0, 3.0, 4.0];
let variogram = VariogramModel::spherical(1.5, 1.0, 0.1);
let mut kriging = OrdinaryKriging::new(&points.view(), &values.view(), variogram).unwrap();
kriging.fit().unwrap();
let prediction = kriging.predict(&[0.5, 0.5]).unwrap();
println!("Predicted: {:.3} ± {:.3}", prediction.value, prediction.variance.sqrt());Sourcepub fn predict_batch(
&self,
locations: &ArrayView2<'_, f64>,
) -> SpatialResult<Vec<KrigingPrediction>>
pub fn predict_batch( &self, locations: &ArrayView2<'_, f64>, ) -> SpatialResult<Vec<KrigingPrediction>>
Sourcepub fn variogram(&self) -> &VariogramModel
pub fn variogram(&self) -> &VariogramModel
Get the variogram model
Sourcepub fn cross_validate(&self) -> SpatialResult<Array1<f64>>
pub fn cross_validate(&self) -> SpatialResult<Array1<f64>>
Cross-validation: leave-one-out prediction errors
§Returns
- Array of prediction errors (predicted - actual)
Trait Implementations§
Source§impl Clone for OrdinaryKriging
impl Clone for OrdinaryKriging
Source§fn clone(&self) -> OrdinaryKriging
fn clone(&self) -> OrdinaryKriging
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for OrdinaryKriging
impl RefUnwindSafe for OrdinaryKriging
impl Send for OrdinaryKriging
impl Sync for OrdinaryKriging
impl Unpin for OrdinaryKriging
impl UnwindSafe for OrdinaryKriging
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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
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>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
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
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.