stacie.cutoff module

Criteria for selecting the part of the spectrum to fit to.

class CV2LCriterion(*, fcut_factor=1.25, log=False, cond=1000000.0, precondition=True, regularize=True)[source]

Bases: CutoffCriterion

Criterion based on the difference between fits to two halves of the spectrum.

Parameters:
cond: float

The threshold for the condition number of the preconditioned covariance matrix.

Due to the preconditioning, the condition number should be close to 1.0. If not, the linear dependence of the parameters is too strong, making the fit unreliable. In this case, “inf” is returned as the criterion.

fcut_factor: float

The scale factor to apply to the cutoff frequency.

If 1.0, the same part of the spectrum is used as in the full non-linear regression. By using a larger value, the default, the criterion also tests whether the fitted parameters can (somewhat) extrapolate to larger frequencies, which reduces the risk of underfitting. This results in less bias on the autocorrelation integral, but slightly larger variance.

log: bool

Whether to fit a linearized model to the logarithm of the spectrum.

property name: str

The name of the criterion.

precondition: bool

Whether to precondition the covariance eigendecomposition.

This option is only disabled for testing. Always leave it enabled in production.

regularize: bool

Whether to regularize the linear regression.

This option is only disabled for testing. Always leave it enabled in production. It will only have an impact on very ill-conditioned fits.

class CutoffCriterion[source]

Bases: object

Base class for cutoff criteria.

Subclasses should implement the __call__ method.

property name: str

The name of the criterion.

linear_weighted_regression(dm, ev, ws, lc=None, ridge=0.0)[source]

Perform a linear regression with multiple weight vectors.

This is a helper function for cv2l_criterion.

Parameters:
  • dm (ndarray[tuple[Any, ...], dtype[float]]) – The design matrix. Shape (neq, npar), where neq is the number of equations and npar is the number of parameters.

  • ev (ndarray[tuple[Any, ...], dtype[float]]) – The expected values, with standard normal measurement errors. Shape (neq,).

  • ws (ndarray[tuple[Any, ...], dtype[float]]) – A set of weight vectors for the rows of dm (equations). Shape (nw, neq), where nw is the number of weight vectors.

  • lc (ndarray[tuple[Any, ...], dtype[float]] | None) – Linear combinations of solutions for different weights to be computed. Shape (nlc, nw), where nlc is the number of linear combinations. If None, the identity matrix is used with shape (nw, nw).

  • ridge (float)

Return type:

tuple[ndarray[tuple[Any, ...], dtype[float]], ndarray[tuple[Any, ...], dtype[float]]]

Returns:

  • xs – The regression coefficients for each weight vector. Shape (nw, npar).

  • cs – The covariance matrices for each combination of weight vector. Shape (nw, npar, nw, npar).

switch_func(x, cutoff, exponent)[source]

Evaluate the switching function at a given points x.

Return type:

ndarray[tuple[Any, ...], dtype[float]]

Parameters: