Spectral Analysis
Spectral analysis tools for financial networks.
This module provides functions for spectral analysis of financial networks,
including eigendecomposition, spectral gap identification, and diffusion modes.
-
scr_financial.network.spectral.compute_laplacian(adjacency_matrix, normalized=True)[source]
Compute the graph Laplacian from an adjacency matrix.
- Parameters:
-
- Returns:
Graph Laplacian matrix as an ndarray.
- Return type:
ndarray
-
scr_financial.network.spectral.eigendecomposition(laplacian)[source]
Perform eigendecomposition of the Laplacian matrix.
- Parameters:
laplacian (ndarray) – Graph Laplacian matrix.
- Returns:
Tuple of (eigenvalues, eigenvectors).
- Return type:
Tuple[ndarray, ndarray]
-
scr_financial.network.spectral.find_spectral_gap(eigenvalues, min_index=1, max_index=None)[source]
Identify the spectral gap in the eigenvalue spectrum.
- Parameters:
eigenvalues (ndarray) – Array of eigenvalues.
min_index (int) – Minimum index to consider. Defaults to 1.
max_index (int | None) – Maximum index to consider. Defaults to None (half of
spectrum).
- Returns:
Tuple of (gap index, gap size).
- Return type:
Tuple[int, float]
-
scr_financial.network.spectral.compute_diffusion_modes(laplacian, k)[source]
Compute the first k diffusion modes of the network.
- Parameters:
-
- Returns:
Tuple of (eigenvalues, eigenvectors) for the first k modes.
- Return type:
Tuple[ndarray, ndarray]
-
scr_financial.network.spectral.analyze_spectral_properties(eigenvalues, eigenvectors)[source]
Analyze spectral properties of the network.
- Parameters:
-
- Returns:
Dictionary containing spectral properties.
- Raises:
ValueError – If eigenvalues has fewer than 2 elements.
- Return type:
dict
-
scr_financial.network.spectral.compute_spectral_embedding(laplacian, dim=2)[source]
Compute spectral embedding of the network.
- Parameters:
-
- Returns:
Spectral embedding matrix of shape (n_nodes, dim).
- Return type:
ndarray
-
scr_financial.network.spectral.compute_diffusion_distance(laplacian, t=1.0, k=None)[source]
Compute diffusion distance matrix at time t.
Uses a fully vectorised NumPy/SciPy implementation. Memory complexity is
O(n²·k) due to the pairwise squared-distance computation.
- Parameters:
laplacian (ndarray) – Graph Laplacian matrix.
t (float) – Diffusion time. Defaults to 1.0.
k (int | None) – Number of eigenmodes to use. Defaults to None (use all).
- Returns:
Symmetric diffusion distance matrix of shape (n_nodes, n_nodes) with
zeros on the diagonal.
- Return type:
ndarray