SpectralState.from_result#
- classmethod SpectralState.from_result(result, *, active_threshold=None)[source]#
Compute every coordinate from a fitted result.
The weights are formed from the result’s
effective_amplitudesquared, with a \(10^{-12}\) floor on the row sums so a row of silent components gives a uniform-in-nothing zero weight rather than a division by zero; the entropy floors each weight the same way inside the logarithm. The velocity loop is \(O(r K \log K)\) and the correlation \(O(r K^2)\).- Parameters:
result (
NSSDNResult) – A fittedNSSDNResult.active_threshold (
float|None) – Weight floor in \([0, 1]\); the package default (\(10^{-2}\)) whenNone.
- Return type:
- Returns:
The populated state, with
nobsequal to the result’s path rows.- Raises:
SpecificationError – If the threshold lies outside \([0, 1]\).
Example
>>> import numpy as np >>> from ns_sdn.spectral_decomposition import NSSDN, Stage >>> y = np.sin(0.3 * np.arange(160.0)) >>> res = NSSDN(y, k=2, state_dim=8, schedule=(Stage(1e-2, 20),), seed=0).fit() >>> state = SpectralState.from_result(res, active_threshold=0.05) >>> state.active_threshold, state.active.shape, state.active.dtype (0.05, (160, 2), dtype('bool')) >>> SpectralState.from_result(res, active_threshold=2.0) Traceback (most recent call last): ... ns_sdn.exceptions.SpecificationError: active_threshold must lie in [0, 1]; got 2.0.