bcam.indar.ema.AAA

class bcam.indar.ema.AAA(*, order: int | None = None, compute_r: bool = True, prune_tol: float = 0.0, d: bool = False, lapack_driver: str | None = None, cond: float | None = None)

Rational approximation using the AAA algorithm.

This is an extension of the AAA algorithm to vector-valued functions using a common-denominator representation. Since this class was created for subsequent use in spectral estimation, it is assumed that the data to be approximated is the DFT of a real signal. Hence, if the data \(y\) has length \(n\), then the rational function \(R(z)\) satisfies

\[R\big(e^{2\pi i k / n}\big) \approx y_k,\quad\text{for } k = 0, \ldots, n-1,\]

where \(y_k = y_{n-k}^*\), and \(R(z) = R(z^*)^*\). Because of the symmetry of the data, instead of \(\{y_k\}_{k=0}^{n-1}\) we work with \(\{y_k\}_{k=0}^{N-1}\) and the parity \(\sigma := n \mod 2\) so that \(n = 2(N-1) + \sigma\).

This class is a sklearn estimator.

Parameters:
orderint

Number of poles of the rational function; recall that complex poles come in conjugate pairs. If order > max_order, where max_order \(= \lfloor \frac{r\cdot n}{r+1} \rfloor\), and \(r\) is the rank of the data, that is, \(y_k \in \mathbb{C}^r\), then order is set to max_order and a warning is raised.

compute_rbool, default True

Whether to compute residues and constant term after fitting poles.

prune_tolfloat, default 0.

Tolerance for pruning poles based on the norm of their residues. If compute_r=False, then residues are computed for pruning, but not updated or stored.

dbool, default False

Whether to include a constant term in the rational function.

lapack_driverstr, default None

LAPACK driver to use for least-squares problems. Should be one of “gelsd”, “gelss”, or “gelsy”. If None, the default driver is used.

condfloat, default None

Condition number threshold for rank estimation in least-squares problems. If None, the default threshold is used.

Attributes:
poles_Poles

Poles of the fitted rational function. To access the real or complex poles, use the attributes poles_.real and poles_.cx, respectively. Only complex poles with positive imaginary part are returned.

r_HCoeffs

Residues of the fitted rational function; only computed if compute_r=True. To access the real or complex residues, use the attributes r_.real and r_.cx, respectively. Only complex residues associated with complex poles with positive imaginary part are returned.

d_np.ndarray

Constant term of the fitted rational function; only computed if compute_r=True.

Methods

fit(y[, parity])

Fit rational function.

get_metadata_routing()

Get metadata routing of this object.

get_params([deep])

Get parameters for this estimator.

predict(X)

Predict using the rational function.

set_fit_request(*[, parity])

Configure whether metadata should be requested to be passed to the fit method.

set_params(**params)

Set the parameters of this estimator.

Notes

A rational function \(R(z) = p(z)/q(z)\) is of type \((l, m)\) if \(p(z)\) is a vector-valued polynomial of degree \(l\), and \(q(z)\) is a scalar polynomial of degree \(m\). When \(l = m\), the \(R\) can be written as

\[R(z) = d + \frac{p_0(z)}{q(z)},\]

where \(d\) is a constant vector, and \(p_0(z)\) has degree at most \(m-1\); by symmetry, \(d\) is real. For spectral estimation \(d = 0\), however, if the parameter d is set to True, then \(d\) is not forced to vanish.

In the computation of the poles, it is assumed that the (generic) condition that all the roots of \(q(z)\) are simple is satisfied.

The AAA algorithm is iterative in the number of poles, and at each step it adds a new support point, so this class stores the indices of the support points for further reuse if the order is increased in a subsequent fit. This property is exploited in the construction of stabilization diagrams.

fit(y: array - like, parity: bool | None = None) AAA

Fit rational function.

Parameters:
yarray-like, shape (N, n_channels)

The data to fit, where for each frequency \(k = 0, \ldots, N-1\), the value \(y_k\) is a vector of length n_channels.

paritybool, optional

Parity of the data as explained in the class docstring. If not given, it is deduced from the imaginary part of the last frequency: if it is negligible, then parity is set to 0, otherwise it is set to 1.

Returns:
selfAAA
get_metadata_routing()

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Returns:
routingMetadataRequest

A MetadataRequest encapsulating routing information.

get_params(deep=True)

Get parameters for this estimator.

Parameters:
deepbool, default=True

If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns:
paramsdict

Parameter names mapped to their values.

predict(X: array - like) ndarray

Predict using the rational function.

Parameters:
Xarray-like, shape (n_eval_points,)

Complex points at which to evaluate the rational function.

Returns:
Rnp.ndarray, shape (n_eval_points, n_channels)

Predicted values.

set_fit_request(*, parity: bool | None | str = '$UNCHANGED$') AAA

Configure whether metadata should be requested to be passed to the fit method.

Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with enable_metadata_routing=True (see sklearn.set_config()). Please check the User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to fit if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to fit.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

Parameters:
paritystr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for parity parameter in fit.

Returns:
selfobject

The updated object.

set_params(**params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as Pipeline). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Parameters:
**paramsdict

Estimator parameters.

Returns:
selfestimator instance

Estimator instance.