compare¶
MATLAB equivalent:
sidCompare
compare ¶
Compare model predicted output to measured data.
compare ¶
compare(model: object, y: ndarray, u: ndarray | None = None, *, initial_state: ndarray | None = None, plot: bool = False) -> CompareResult
Compare model predicted output to measured data.
This is the Python port of sidCompare.m.
Simulates the model's predicted output given the input signal and compares it to the measured output using the NRMSE fit metric:
.. math::
\text{fit} = 100 \left(1 -
\frac{\|y - \hat y\|}{\|y - \bar y\|}\right)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
object
|
Result from any |
required |
y
|
ndarray, shape ``(N, ny)`` or ``(N+1, p, L)``
|
Measured output data. For state-space models the array contains
state trajectories |
required |
u
|
ndarray or None
|
Input data, shape |
None
|
initial_state
|
ndarray or None
|
Initial state vector for state-space simulation, shape |
None
|
plot
|
bool
|
If |
False
|
Returns:
| Type | Description |
|---|---|
CompareResult
|
Frozen dataclass with attributes:
|
Raises:
| Type | Description |
|---|---|
SidError
|
If the model type cannot be determined (code: |
Examples:
Notes
Specification: (Model output comparison -- not yet in SPEC.md)
For state-space models, the simulation propagates:
.. math::
x(k+1) = A(k)\,x(k) + B(k)\,u(k)
from the initial state x0 (default: first row of y). For multi-trajectory data the fit is averaged across trajectories.
See Also
sid.residual : Residual analysis and diagnostic tests. sid._internal.freq_domain_sim.freq_domain_sim : Frequency-domain simulation helper.
Changelog
2026-04-09 : First version (Python port) by Pedro Lourenco.