mvtsa.representation.RecursivePCA#

class mvtsa.representation.RecursivePCA(forgetting=0.99, variable=True, lambda_min=0.9, lambda_max=0.9999, n_components=0.95, lags=0, ridge=1e-06)[source]#

Bases: object

Recursive (exponentially weighted) PCA with a variable forgetting factor.

The mean and covariance are updated sample by sample,

\[d_t = x_t-\mu_{t-1},\quad \mu_t=\mu_{t-1}+(1-\lambda_t)d_t,\quad \Sigma_t=\lambda_t\bigl(\Sigma_{t-1}+(1-\lambda_t)d_td_t^{\mathsf T}\bigr),\]

so that a covariance matrix – and a PCA model – is available at every sampling time. With variable=True the forgetting factor follows the constant-information principle of Fortescue, Kershenbaum and Ydstie (1981): a sample that the current model explains badly (large Mahalanobis distance \(m_t\) of \(d_t\)) shortens the memory,

\[\lambda_t = \operatorname{clip}\bigl(1-(1-\lambda_0)\,m_t/n,\;\lambda_{\min},\;\lambda_{\max}\bigr),\]

which lets the model adapt quickly after a change of the operating range (Dobos and Abonyi, 2012).

Parameters:
forgettingfloat

Nominal forgetting factor \(\lambda_0\) (memory about \(1/(1-\lambda_0)\) samples).

variablebool

Use the variable forgetting factor.

lambda_min, lambda_maxfloat

Bounds of the variable forgetting factor.

n_componentsint or float

Retained components of the current model.

lagsint

Dynamic PCA: the updates use lag-extended samples.

initialize(X)[source]#

Initialize the recursion from a block of data.

model()[source]#

Current eigenvalues and retained loadings (n, p).

update(x)[source]#

Update with one sample; returns the forgetting factor used.