class documentation

Undocumented

Static Method diagsums Diagonally sum matrices a and b. This is practically the same as convolution using FFT.
Static Method eigval_svd Calculate single value decomposition from eigenvalues
Method __init__ Set up initial values of useful constants
Method embed Peform embedding of our data, a, into the trajectory matrix, self.X.
Method get_grouping Define how the eigentriples (evals, evecs, fvecs) should be grouped.
Method group Perform the actual grouping of decomposed elements
Method plot_all Plot all details of SSA. Makes lots of plots
Method plot_component_slices Plots grouped decomposed trajectory matrix of SSA
Method plot_components Plots grouped decomposed trajectory matrix of SSA
Method plot_eigenvectors Plots eigenvectors (left singular vectors) of SSA
Method plot_factorvectors Plots factorvectors (right singular vectors) of SSA
Method plot_ssa Plots an overview of the SSA results
Method plot_svd Plots SVD used in SSA
Method plot_trajectory_decomp Plots decomposed trajectory matrix of SSA
Method plot_trajectory_groups Plots grouped decomposed trajectory matrix of SSA
Method quasi_hankelisation Reverses the embedding map, faster than the direct method but less accurate. Is almost always good enough.
Method reverse_mapping Reverses the embedding map. This version is slow but more accurate, use quasi_hankelisation instead in most applications
Instance Variable a Undocumented
Instance Variable d Undocumented
Instance Variable grouping Undocumented
Instance Variable k Undocumented
Instance Variable K Undocumented
Instance Variable l Undocumented
Instance Variable L Undocumented
Instance Variable m Undocumented
Instance Variable n Undocumented
Instance Variable N Undocumented
Instance Variable ndim Undocumented
Instance Variable s_g Undocumented
Instance Variable u_g Undocumented
Instance Variable v_star_g Undocumented
Instance Variable X Undocumented
Instance Variable X_decomp Undocumented
Instance Variable X_g Undocumented
@staticmethod
def diagsums(a: Array_2D, b: Array_2D, mode: Convolution_Mode_literals = 'full', fac: int | float = 1) -> Array_2D:

Diagonally sum matrices a and b. This is practically the same as convolution using FFT.

# ARGUMENTS #

a : Array_2D b : Array_2D mode : Convolution_Mode_literals = 'full'

Convolution mode to use
fac : int | float = 1
Factor to multiply convolution by.
# RETURNS #
conv : Array_2D
Diagonal sum of a and b
@staticmethod
def eigval_svd(X: Array_2D, n_eigen_values: None | int = None):

Calculate single value decomposition from eigenvalues

def __init__(self, a: Array_1D | Array_2D, w_shape: None | int | tuple[N] | tuple[N, M] = None, svd_strategy: SVD_Strategy_Literals = 'eigval', rev_mapping: Reverse_Mapping_Strategy_Literals = 'fft', grouping: dict[str, Any] = {'mode': 'elementary'}, n_eigen_values: None | int = None):

Set up initial values of useful constants

# ARGUMENTS #

a : [nx] | [nx,ny]
Array to operate on, should be 1D or 2D.
w_shape : None | int | [wx] | [wx, wy]
Window shape to use for SSA, no array is actually created from this shape, it's used as indices to loops etc. If not given, will use a.shape//4 as window size
svd_strategy : 'eigval' | 'numpy'
How should we calculate single value decomposition, 'eigval' is fastest and uses least memory so it's normally the best choice.
rev_mapping : 'fft' | 'direct'
How should we reverse the embedding? 'fft' is fastest so normally best.
grouping : dict[str, Any]

How should we group the tarjectory matricies? Values other than 'elementary' do not give exact results. Some modes require extra arguments detailed below:

## Required Keys ##
'mode' : 'elementary'
'pairs'
'pairs_after_first'
'similar_eigenvalues'
'blocks_of_n'

Required to set the mode, default is 'elementary'. Values other than 'elementary' do not give exact results. Some values require extra keys.

### Required for 'mode'='similar_eigenvalues' ###
'tolerance' : float
Maximum fractional difference that two eigenvalues can have if their eigenvectors are to be grouped into one eigenvector.
### Required for 'mode'='blocks_of_n' ###
'n' : int
Number of eigenvectors to be grouped together in each group.
n_eigen_values : None | int
Number of eigenvalues/vectors that should be used in calculations. None means to use all of them.

# RETURNS #

Nothing, but the object will hold the single spectrum analysis of the array 'a' in self.X_ssa
def embed(self, a: Array_1D | Array_2D) -> Array_2D:

Peform embedding of our data, a, into the trajectory matrix, self.X.

def get_grouping(self, mode: Grouping_Mode_Literals = 'elementary', **kwargs) -> list[list[int]]:

Define how the eigentriples (evals, evecs, fvecs) should be grouped.

# ARGUMENTS #
mode : str
How the grouping will be performed
**kwargs : Dict[str,Any]
Data required depending upon mode, see SSA.__init__ docstring for details
# RETURNS #
grouping : list[list[int]]
List of indices that will make up each group.
def group(self) -> tuple[Array_3D, Array_2D, Array_2D, Array_2D]:

Perform the actual grouping of decomposed elements

Takes lists of indices from self.grouping, and sums decomposed elements with those indices i.e., self.grouping=[[0], [1,2,3], [4,5,6,7], [9]] then grouped components are X_g = [ X_0, X_1+X_2+X_3, X_4+X_5+X_6+X_7, X_9]

# ARGUMENTS #
None, but uses self.X_decomp, self.u, self.s, self.v_star, self.grouping, self.d, self.m
# RETURNS #
X_g : Array_3D
Grouped matrixes
u_g : Array_2D
Grouped left singular vectors
v_star_g : Array_2D
Grouped right singular vectors
s_g : Array_2D
Grouped singular values
def plot_all(self, n_max=36):

Plot all details of SSA. Makes lots of plots

def plot_component_slices(self, slice_tuples: list[tuple[int, int]]):

Plots grouped decomposed trajectory matrix of SSA

def plot_components(self, n_max=None):

Plots grouped decomposed trajectory matrix of SSA

def plot_eigenvectors(self, n_max=None):

Plots eigenvectors (left singular vectors) of SSA

def plot_factorvectors(self, n_max=None):

Plots factorvectors (right singular vectors) of SSA

def plot_ssa(self, n=4, noise_estimate=None):

Plots an overview of the SSA results

def plot_svd(self, recomp_n=None):

Plots SVD used in SSA

def plot_trajectory_decomp(self, n_max=None):

Plots decomposed trajectory matrix of SSA

def plot_trajectory_groups(self, n_max=None):

Plots grouped decomposed trajectory matrix of SSA

def quasi_hankelisation(self) -> Array_2D | Array_3D:

Reverses the embedding map, faster than the direct method but less accurate. Is almost always good enough.

# RETURNS #
X_ssa : Array_2D | Array_3D
2D (for 1D input data) or 3D (for 2D input data) singular spectrum analysis components. First index is the component number.
def reverse_mapping(self) -> Array_2D | Array_3D:

Reverses the embedding map. This version is slow but more accurate, use quasi_hankelisation instead in most applications

# RETURNS #
X_ssa : Array_2D | Array_3D
2D (for 1D input data) or 3D (for 2D input data) singular spectrum analysis components. First index is the component number.
a =

Undocumented

d =

Undocumented

grouping =

Undocumented

k =

Undocumented

K =

Undocumented

l =

Undocumented

L =

Undocumented

m =

Undocumented

n =

Undocumented

N =

Undocumented

ndim =

Undocumented

s_g =

Undocumented

u_g =

Undocumented

v_star_g =

Undocumented

X =

Undocumented

X_decomp =

Undocumented

X_g =

Undocumented