model_order¶
MATLAB equivalent:
sidModelOrder
model_order ¶
Estimate model order from frequency response via Hankel SVD.
model_order ¶
model_order(result: object, *, horizon: int | None = None, threshold: float | None = None) -> tuple[int, dict]
Estimate model order from frequency response data.
This is the Python port of sidModelOrder.m.
Estimates the state dimension n of a linear system from the singular value decomposition of a block Hankel matrix built from impulse response coefficients. The impulse response is obtained via IFFT of the frequency response estimate.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
FreqResult
|
Result from any |
required |
horizon
|
int or None
|
Block Hankel prediction horizon r.
Default: |
None
|
threshold
|
float or None
|
If specified, count singular values with
|
None
|
Returns:
| Name | Type | Description |
|---|---|---|
n |
int
|
Estimated model order (state dimension). |
sv_dict |
dict
|
Dictionary with keys:
|
Raises:
| Type | Description |
|---|---|
SidError
|
If result is missing required attributes (code:
|
SidError
|
If horizon is not a positive integer (code:
|
SidError
|
If threshold is not a positive scalar (code:
|
SidError
|
If the impulse response is too short for a Hankel matrix (code:
|
Examples:
Automated model order detection:
With a threshold:
Notes
Specification: SPEC.md section 8.12 -- Output-COSMIC: Partial State Observation
Algorithm:
- Compute impulse response
g(k)via IFFT of the frequency response, using a conjugate-symmetric extension to obtain a real-valued sequence. - Build block Hankel matrix H with r block-rows and r
block-columns. For MIMO systems each entry
g(k)is an(ny, nu)block. - Compute SVD of H.
- Detect model order as
argmax_k (sigma_k / sigma_{k+1})(gap method) or count singular values above threshold.
References:
Kung, S.Y. "A new identification and model reduction algorithm via singular value decomposition." Proc. 12th Asilomar Conference, 1978.
See Also
sid.freq_bt : Blackman-Tukey frequency response estimation. sid.freq_etfe : Empirical transfer function estimate.
Changelog
2026-04-09 : First version (Python port) by Pedro Lourenco.