pub struct MeasurementCorrelationAnalyzer {
pub n_measurements: usize,
pub correlation_window: usize,
}Expand description
Analyses pairwise correlations among measurement channels to detect coordinated attacks.
A coordinated FDI attack on multiple sensors often breaks the expected correlation structure; this analyzer computes the Frobenius distance between a current correlation matrix and a baseline.
Fields§
§n_measurements: usizeNumber of measurement channels.
correlation_window: usizeNumber of most-recent time steps used for rolling correlation.
Implementations§
Source§impl MeasurementCorrelationAnalyzer
impl MeasurementCorrelationAnalyzer
Sourcepub fn new(n_measurements: usize, window: usize) -> Self
pub fn new(n_measurements: usize, window: usize) -> Self
Create an analyzer for n_measurements channels with a rolling window.
Sourcepub fn compute_correlation(&self, history: &[Vec<f64>]) -> Vec<Vec<f64>>
pub fn compute_correlation(&self, history: &[Vec<f64>]) -> Vec<Vec<f64>>
Compute the n × n Pearson correlation matrix from measurement history.
history[i][t] is the value of measurement channel i at time t.
The last correlation_window time steps are used.
Sourcepub fn detect_correlation_change(
&self,
current_window: &[Vec<f64>],
baseline_correlation: &[Vec<f64>],
) -> f64
pub fn detect_correlation_change( &self, current_window: &[Vec<f64>], baseline_correlation: &[Vec<f64>], ) -> f64
Detect a structural change in measurement correlations.
Computes the current correlation matrix from current_window and returns
the Frobenius norm of the difference against baseline_correlation.
Trait Implementations§
Source§impl Clone for MeasurementCorrelationAnalyzer
impl Clone for MeasurementCorrelationAnalyzer
Source§fn clone(&self) -> MeasurementCorrelationAnalyzer
fn clone(&self) -> MeasurementCorrelationAnalyzer
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<'de> Deserialize<'de> for MeasurementCorrelationAnalyzer
impl<'de> Deserialize<'de> for MeasurementCorrelationAnalyzer
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for MeasurementCorrelationAnalyzer
impl RefUnwindSafe for MeasurementCorrelationAnalyzer
impl Send for MeasurementCorrelationAnalyzer
impl Sync for MeasurementCorrelationAnalyzer
impl Unpin for MeasurementCorrelationAnalyzer
impl UnsafeUnpin for MeasurementCorrelationAnalyzer
impl UnwindSafe for MeasurementCorrelationAnalyzer
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
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>
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
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§unsafe fn to_subset_unchecked(&self) -> SS
unsafe 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.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.