Trait ndarray_stats::DeviationExt
source · pub trait DeviationExt<A, S, D>{
// Required methods
fn count_eq<T>(
&self,
other: &ArrayBase<T, D>,
) -> Result<usize, MultiInputError>
where A: PartialEq,
T: Data<Elem = A>;
fn count_neq<T>(
&self,
other: &ArrayBase<T, D>,
) -> Result<usize, MultiInputError>
where A: PartialEq,
T: Data<Elem = A>;
fn sq_l2_dist<T>(
&self,
other: &ArrayBase<T, D>,
) -> Result<A, MultiInputError>
where A: AddAssign + Clone + Signed,
T: Data<Elem = A>;
fn l2_dist<T>(
&self,
other: &ArrayBase<T, D>,
) -> Result<f64, MultiInputError>
where A: AddAssign + Clone + Signed + ToPrimitive,
T: Data<Elem = A>;
fn l1_dist<T>(&self, other: &ArrayBase<T, D>) -> Result<A, MultiInputError>
where A: AddAssign + Clone + Signed,
T: Data<Elem = A>;
fn linf_dist<T>(
&self,
other: &ArrayBase<T, D>,
) -> Result<A, MultiInputError>
where A: Clone + PartialOrd + Signed,
T: Data<Elem = A>;
fn mean_abs_err<T>(
&self,
other: &ArrayBase<T, D>,
) -> Result<f64, MultiInputError>
where A: AddAssign + Clone + Signed + ToPrimitive,
T: Data<Elem = A>;
fn mean_sq_err<T>(
&self,
other: &ArrayBase<T, D>,
) -> Result<f64, MultiInputError>
where A: AddAssign + Clone + Signed + ToPrimitive,
T: Data<Elem = A>;
fn root_mean_sq_err<T>(
&self,
other: &ArrayBase<T, D>,
) -> Result<f64, MultiInputError>
where A: AddAssign + Clone + Signed + ToPrimitive,
T: Data<Elem = A>;
fn peak_signal_to_noise_ratio<T>(
&self,
other: &ArrayBase<T, D>,
maxv: A,
) -> Result<f64, MultiInputError>
where A: AddAssign + Clone + Signed + ToPrimitive,
T: Data<Elem = A>;
fn __private__(&self, _: PrivateMarker);
}
Expand description
An extension trait for ArrayBase
providing functions
to compute different deviation measures.
Required Methods§
sourcefn count_eq<T>(&self, other: &ArrayBase<T, D>) -> Result<usize, MultiInputError>
fn count_eq<T>(&self, other: &ArrayBase<T, D>) -> Result<usize, MultiInputError>
Counts the number of indices at which the elements of the arrays self
and other
are equal.
The following errors may be returned:
MultiInputError::EmptyInput
ifself
is emptyMultiInputError::ShapeMismatch
ifself
andother
don’t have the same shape
sourcefn count_neq<T>(
&self,
other: &ArrayBase<T, D>,
) -> Result<usize, MultiInputError>
fn count_neq<T>( &self, other: &ArrayBase<T, D>, ) -> Result<usize, MultiInputError>
Counts the number of indices at which the elements of the arrays self
and other
are not equal.
The following errors may be returned:
MultiInputError::EmptyInput
ifself
is emptyMultiInputError::ShapeMismatch
ifself
andother
don’t have the same shape
sourcefn sq_l2_dist<T>(&self, other: &ArrayBase<T, D>) -> Result<A, MultiInputError>
fn sq_l2_dist<T>(&self, other: &ArrayBase<T, D>) -> Result<A, MultiInputError>
Computes the squared L2 distance between self
and other
.
n
∑ |aᵢ - bᵢ|²
i=1
where self
is a
and other
is b
.
The following errors may be returned:
MultiInputError::EmptyInput
ifself
is emptyMultiInputError::ShapeMismatch
ifself
andother
don’t have the same shape
sourcefn l2_dist<T>(&self, other: &ArrayBase<T, D>) -> Result<f64, MultiInputError>
fn l2_dist<T>(&self, other: &ArrayBase<T, D>) -> Result<f64, MultiInputError>
Computes the L2 distance between self
and other
.
n
√ ( ∑ |aᵢ - bᵢ|² )
i=1
where self
is a
and other
is b
.
The following errors may be returned:
MultiInputError::EmptyInput
ifself
is emptyMultiInputError::ShapeMismatch
ifself
andother
don’t have the same shape
Panics if the type cast from A
to f64
fails.
sourcefn l1_dist<T>(&self, other: &ArrayBase<T, D>) -> Result<A, MultiInputError>
fn l1_dist<T>(&self, other: &ArrayBase<T, D>) -> Result<A, MultiInputError>
Computes the L1 distance between self
and other
.
n
∑ |aᵢ - bᵢ|
i=1
where self
is a
and other
is b
.
The following errors may be returned:
MultiInputError::EmptyInput
ifself
is emptyMultiInputError::ShapeMismatch
ifself
andother
don’t have the same shape
sourcefn linf_dist<T>(&self, other: &ArrayBase<T, D>) -> Result<A, MultiInputError>
fn linf_dist<T>(&self, other: &ArrayBase<T, D>) -> Result<A, MultiInputError>
Computes the L∞ distance between self
and other
.
max(|aᵢ - bᵢ|)
ᵢ
where self
is a
and other
is b
.
The following errors may be returned:
MultiInputError::EmptyInput
ifself
is emptyMultiInputError::ShapeMismatch
ifself
andother
don’t have the same shape
sourcefn mean_abs_err<T>(
&self,
other: &ArrayBase<T, D>,
) -> Result<f64, MultiInputError>
fn mean_abs_err<T>( &self, other: &ArrayBase<T, D>, ) -> Result<f64, MultiInputError>
Computes the mean absolute error between self
and other
.
n
1/n * ∑ |aᵢ - bᵢ|
i=1
where self
is a
and other
is b
.
The following errors may be returned:
MultiInputError::EmptyInput
ifself
is emptyMultiInputError::ShapeMismatch
ifself
andother
don’t have the same shape
Panics if the type cast from A
to f64
fails.
sourcefn mean_sq_err<T>(
&self,
other: &ArrayBase<T, D>,
) -> Result<f64, MultiInputError>
fn mean_sq_err<T>( &self, other: &ArrayBase<T, D>, ) -> Result<f64, MultiInputError>
Computes the mean squared error between self
and other
.
n
1/n * ∑ |aᵢ - bᵢ|²
i=1
where self
is a
and other
is b
.
The following errors may be returned:
MultiInputError::EmptyInput
ifself
is emptyMultiInputError::ShapeMismatch
ifself
andother
don’t have the same shape
Panics if the type cast from A
to f64
fails.
sourcefn root_mean_sq_err<T>(
&self,
other: &ArrayBase<T, D>,
) -> Result<f64, MultiInputError>
fn root_mean_sq_err<T>( &self, other: &ArrayBase<T, D>, ) -> Result<f64, MultiInputError>
Computes the unnormalized root-mean-square error between self
and other
.
√ mse(a, b)
where self
is a
, other
is b
and mse
is the mean-squared-error.
The following errors may be returned:
MultiInputError::EmptyInput
ifself
is emptyMultiInputError::ShapeMismatch
ifself
andother
don’t have the same shape
Panics if the type cast from A
to f64
fails.
sourcefn peak_signal_to_noise_ratio<T>(
&self,
other: &ArrayBase<T, D>,
maxv: A,
) -> Result<f64, MultiInputError>
fn peak_signal_to_noise_ratio<T>( &self, other: &ArrayBase<T, D>, maxv: A, ) -> Result<f64, MultiInputError>
Computes the peak signal-to-noise ratio between self
and other
.
10 * log10(maxv^2 / mse(a, b))
where self
is a
, other
is b
, mse
is the mean-squared-error
and maxv
is the maximum possible value either array can take.
The following errors may be returned:
MultiInputError::EmptyInput
ifself
is emptyMultiInputError::ShapeMismatch
ifself
andother
don’t have the same shape
Panics if the type cast from A
to f64
fails.
sourcefn __private__(&self, _: PrivateMarker)
fn __private__(&self, _: PrivateMarker)
This method makes this trait impossible to implement outside of
ndarray-stats
so that we can freely add new methods, etc., to
this trait without breaking changes.
We don’t anticipate any other crates needing to implement this trait, but if you do have such a use-case, please let us know.
Warning This method is not considered part of the public API, and client code should not rely on it being present. It may be removed in a non-breaking release.