fuzzyclust.models.simulate_free_run#
- fuzzyclust.models.simulate_free_run(model, u, y_init, n_a, n_b=0, n_k=1)[source]#
Free-run (parallel) simulation of a NARX model.
The regressors follow the layout of
make_regressors(). The predicted outputs are fed back as regressors instead of the measured ones, \(\hat y_k = f(\hat y_{k-1},\dots,\hat y_{k-n_a}, u_{k-n_k},\dots)\), which is the demanding test of a dynamic model (errors can accumulate).- Parameters:
- model
fittedregressorwithpredict Takes rows ordered as the regressors of
make_regressors: lagged outputs first (lag 1 for all outputs, then lag 2, …), then lagged inputs.- uarray_like
ofshape(T,)or(T,n_inputs)orNone Input sequence (
Nonefor an autonomous model).- y_initarray_like
ofshape(max_lag,)or(max_lag,n_outputs) Initial outputs (the first
max_lagmeasured values).- n_a, n_b, n_k
int Model orders and dead time, as used for
make_regressors.
- model
- Returns:
- y_sim
ndarrayofshape(T,)or(T,n_outputs) Simulated output; the first
max_lagentries arey_init.
- y_sim
Examples
>>> import numpy as np >>> from fuzzyclust.preprocessing import make_regressors >>> from fuzzyclust.models import TakagiSugeno, simulate_free_run, make_second_order_plant >>> u, y = make_second_order_plant(n_samples=150, random_state=0) >>> Phi, target, _ = make_regressors(y, u, n_a=2, n_b=1, n_k=0) >>> ts = TakagiSugeno(n_clusters=4, random_state=0).fit(Phi, target) >>> y_sim = simulate_free_run(ts, u, y[:2], n_a=2, n_b=1, n_k=0) >>> y_sim.shape (150,)
Examples using fuzzyclust.models.simulate_free_run#
Identification of a nonlinear dynamic system with free-run validation
MIMO Takagi–Sugeno model with local MIMO ARX consequents