pub struct CorrelationMatrix {
pub matrix: Vec<Vec<f64>>,
pub n: usize,
}Expand description
Symmetric correlation matrix.
Fields§
§matrix: Vec<Vec<f64>>Row-major correlation values; element [i * n + j] is corr(i, j).
n: usizeDimension (number of assets).
Implementations§
Source§impl CorrelationMatrix
impl CorrelationMatrix
Sourcepub fn from_returns(returns: &[Vec<f64>]) -> Self
pub fn from_returns(returns: &[Vec<f64>]) -> Self
Compute pairwise Pearson correlation from a matrix of return series.
returns[i] is the time-series of returns for asset i.
All series must have the same length.
Sourcepub fn is_positive_definite(&self) -> bool
pub fn is_positive_definite(&self) -> bool
Test positive definiteness using Sylvester’s criterion.
Checks that all leading principal minors are strictly positive. Uses Gaussian elimination to compute determinants.
Sourcepub fn eigenvalues_approx(&self) -> Vec<f64>
pub fn eigenvalues_approx(&self) -> Vec<f64>
Approximate the three largest eigenvalues via power iteration with deflation.
Returns up to three eigenvalues (fewer if the matrix is smaller).
Sourcepub fn condition_number(&self) -> f64
pub fn condition_number(&self) -> f64
Approximate condition number: ratio of largest to smallest (absolute) eigenvalue.
Trait Implementations§
Source§impl Clone for CorrelationMatrix
impl Clone for CorrelationMatrix
Auto Trait Implementations§
impl Freeze for CorrelationMatrix
impl RefUnwindSafe for CorrelationMatrix
impl Send for CorrelationMatrix
impl Sync for CorrelationMatrix
impl Unpin for CorrelationMatrix
impl UnsafeUnpin for CorrelationMatrix
impl UnwindSafe for CorrelationMatrix
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