estimator
CUSUM estimator components.
Provides estimating schemas that maintain online parameter estimates for
generalized CUSUM algorithms. Each schema implements the
IEstimatingSchema
interface, supporting training on a learning sample, optional adaptive
updates with new observations, and state reset.
Public API
GaussianMLESchema: Estimates mean and covariance using Welford’s numerically stable online algorithm. Supports multivariate observations. See
gaussian_mlefor details.GaussianARSchema: Fits a univariate autoregressive (AR) model via the
archpackage. Requires the optionalarchdependency. Seegaussian_arfor details.
Examples
Gaussian mean/covariance estimation:
>>> import numpy as np
>>> from pysatl_cpd.algorithms.online.cusum.component.estimator import GaussianMLESchema
>>> schema = GaussianMLESchema(adaptive=True)
>>> schema.train([np.array([1.0]), np.array([2.0]), np.array([3.0])])
>>> round(float(schema.mean[0]), 2)
2.0
>>> schema.update(np.array([4.0]))
>>> round(float(schema.mean[0]), 2)
2.5
Autoregressive estimation (requires the arch package):
>>> from pysatl_cpd.algorithms.online.cusum.component.estimator import GaussianARSchema
>>> schema = GaussianARSchema(autoreg_order=1, adaptive=True)
>>> schema.train([np.array([1.0]), np.array([2.0]), np.array([3.0]), np.array([4.0])])
>>> estimates = schema.estimates
>>> round(estimates["noise_variance"], 4)
0.0
Notes
GaussianARSchemarequires the optionalarchdependency. Install it viapoetry add archor your preferred method.GaussianARSchemaonly supports univariate observations (dim=1).GaussianMLESchemasupports multivariate observations of any dimension.Both schemas implement the
IEstimatingSchemaprotocol defined inpysatl_cpd.algorithms.online.cusum.abstracts.estimator.