Main Content

simsd

Simulate linear models with uncertainty using Monte Carlo method

Description

simsdsimulates linear models using the Monte Carlo method. The command performs multiple simulations using different values of the uncertain parameters of the model, and different realizations of additive noise and simulation initial conditions.simsduses Monte Carlo techniques to generate response uncertainty, whereassimgenerates the uncertainty using the Gauss Approximation Formula.

example

simsd(sys,udata)simulates and plots the response of 10 perturbed realizations of the identified modelsys. Simulation input dataudatais used to compute the simulated response.

The parameters of the perturbed realizations ofsysare consistent with the parameter covariance of the original model,sys. Ifsysdoes not contain parameter covariance information, the 10 simulated responses are identical. For information about how the parameter covariance information is used to generate the perturbed models, seeGenerating Perturbations of Identified Model.

example

simsd(sys,udata,N)simulates and plots the response ofNperturbed realizations of the identified modelsys.

example

simsd(sys,udata,N,opt)simulates the system response using the simulation behavior specified in the option setopt. Useoptto specify uncertainties in the initial conditions and include the effect of additive disturbances.

The simulated responses are all identical ifsysdoes not contain parameter covariance information, and you do not specify additive noise or covariance values for initial states. You specify these values in theAddNoiseandX0Covarianceoptions ofopt.

example

y= simsd(___)returns theNsimulation results inyas a cell array. No simulated response plot is produced. Use with any of the input argument combinations in the previous syntaxes.

example

[y,y_sd] = simsd(___)还返回估计标准偏差y_sdfor the simulated response.

Examples

collapse all

Load the estimation data.

loadiddata1z1

z1is aniddataobject that stores the input-output estimation data.

Estimate a third-order state-space model.

sys = ssest(z1,3);

Simulate the response of the estimated model using the Monte Carlo method and input estimation data, and plot the response.

simsd(sys,z1);

Figure Created by subreferencing I/O pairs of a previously estimated model. contains an axes object. The axes object with title Simulated output#1: y1, xlabel Time (seconds), ylabel y indexOf 1 baseline y_1 contains 11 objects of type line. These objects represent y1, Nominal.

The blue line plots the simulated response of the original nominal modelsys. The green lines plot the simulated response of 10 perturbed realizations ofsys.

Simulate an estimated model using the Monte Carlo method for a specified number of model perturbations.

Estimate a second-order state-space model using estimation data. Obtainsysin the observability canonical form.

loadiddata3z3sys = ssest(z3,2,'Form','canonical');

Compute the simulated response of the estimated model using the Monte Carlo method, and plot the responses. Specify the number of random model perturbations as 20.

N = 20; simsd(sys,z3,N)

Figure Created by subreferencing I/O pairs of a previously estimated model. contains an axes object. The axes object with title Simulated output#1: y1, xlabel Time (seconds), ylabel y indexOf 1 baseline y_1 contains 21 objects of type line. These objects represent y1, Nominal.

The blue line plots the simulated response of the original nominal modelsys. The green lines plot the simulated response of the 20 perturbed realizations ofsys.

You can also obtain the simulated response for each perturbation ofsys. No plot is generated when you use this syntax.

y = simsd(sys,z3,N);

yis the simulated response, returned as a cell array ofN+1 elements.y{1}contains the nominal response forsys. The remaining elements contain the simulated response for theNperturbed realizations.

Load time series data.

loadiddata9z9

z9is aniddataobject with 200 output data samples and no inputs.

Estimate a sixth-order AR model using the least-squares algorithm.

sys = ar(z9,6,'ls');

For time series data, specify the desired simulation length,Ns= 200 using anNs-by-0 input data set.

data = iddata([],zeros(200,0),z9.Ts);

Set the initial conditions to use the initial samples of the time series as historical output samples. The past data is mapped to the initial states of each perturbed system individually.

IC = struct('Input',[],'Output',z9.y(1:6)); opt = simsdOptions('InitialCondition',IC);

Simulate the model using Monte Carlo method and specified initial conditions. Specify the number of random model perturbations as 20.

simsd(sys,data,20,opt)

Figure Created by subreferencing I/O pairs of a previously estimated model. contains an axes object. The axes object with title Simulated output#1: y1, xlabel Time (seconds), ylabel y indexOf 1 baseline y_1 contains 21 objects of type line. These objects represent y1, Nominal.

The blue line plots the simulated response of the original nominal modelsys. The green lines plot the simulated response of the 20 perturbed realizations ofsys.

Load data, and split it into estimation and simulation data.

loadiddata3ze = z3(1:200); zsim = z3(201:256);

Estimate a second-order state-space modelsysusing estimation data. Specify that no parameter covariance data is generated. Obtainsysin the observability canonical form.

opt = ssestOptions('EstimateCovariance',false); sys = ssest(ze,2,'Form','canonical',opt);

Set the initial conditions for simulating the estimated model. Specify initial state valuesx0for the two states and also the covariance of initial state valuesx0Cov. The covariance is specified as a 2-by-2 matrix because there are two states.

x0 = [1.2; -2.4]; x0Cov = [0.86 -0.39; -0.39 1.42]; opt = simsdOptions('InitialCondition',x0,'X0Covariance',x0Cov);

Simulate the model using Monte Carlo method and specified initial conditions. Specify the number of random model perturbations as 100.

simsd(sys,zsim,100,opt)

Figure Created by subreferencing I/O pairs of a previously estimated model. contains an axes object. The axes object with title Simulated output#1: y1, xlabel Time (seconds), ylabel y indexOf 1 baseline y_1 contains 101 objects of type line. These objects represent y1, Nominal.

The blue line plots the simulated response of the original nominal modelsys. The green lines plot the simulated response of the 100 perturbed realizations ofsys. The software uses a different realization of the initial states to simulate each perturbed model. Initial states are drawn from a Gaussian distribution with meanInitialConditionand covarianceX0Covariance.

Load the estimation data.

loadiddata1z1

z1is anidddataobject that stores 300 input-output estimation data samples.

Estimate a second-order state-space model using the estimation data.

sys = ssest(z1,2);

Create a default option set forsimsd, and modify the option set to add noise.

opt = simsdOptions; opt.AddNoise = true;

Compute the simulated response of the estimated model using the Monte Carlo method. Specify the number of random model perturbations as 20, and simulate the model using the specified option set.

[y,y_sd] = simsd(sys,z1,20,opt);

yis the simulated response, returned as a cell array of 21 elements.y{1}contains the nominal, noise-free response forsys. The remaining elements contain the simulated response for the 20 perturbed realizations ofsyswith additive disturbances added to each response.

y_sdis the estimated standard deviation of simulated response, returned as aniddataobject with no inputs. The standard deviations are computed from the 21 simulated outputs. To access the standard deviation, usey_sd.OutputData.

Input Arguments

collapse all

Model to be simulated, specified as one of the following parametric linear identified models:idtf,idproc,idpoly,idss, oridgrey.

To generate the set of simulated responses, the software perturbs the parameters ofsysin a way that is consistent with the parameter covariance information. Usegetcovto examine the parameter uncertainty forsys. For information about how the perturbed models are generated fromsys, seersample.

The simulated responses are all identical ifsysdoes not contain parameter covariance information and you do not specify additive noise or covariance values for initial states. You specify these values in theAddNoiseandX0Covarianceoptions ofopt.

Simulation input data, specified as one of the following:

  • iddataobject — Input data can be either time-domain or frequency-domain. The software uses only the input channels of theiddataobject.

    Ifsysis a time series model, that is, a model with no inputs, specifyudataas anNs-by-0 signal, whereNsis the wanted number of simulation output samples for each of theNperturbed realizations ofsys. For example, to simulate 100 output samples, specifyudataas follows.

    udata = iddata([],zeros(100,0),Ts);

    For an example, seeSimulate Time Series Model Using Monte Carlo Method.

  • matrix — For simulation of discrete-time systems using time-domain data only. Columns of the matrix correspond to each input channel.

If you do not have data from an experiment, useidinputto generate signals with various characteristics.

Number of perturbed realizations ofsysto be simulated, specified as a positive integer.

Simulation options for simulating models using Monte Carlo methods, specified as asimsdOptionsoption set. You can use this option set to specify:

  • Input and output signal offsets — Specify an offset to remove from the input signal and an offset to add to the response ofsys.

  • Initial condition handling — Specify initial conditions for simulation and their covariance. For state-space and linear grey-box models (idssandidgrey), if you want to simulate the effect of uncertainty in initial states, set theInitialConditionoption to a double vector, and specify its covariance using theX0Covarianceoption. For an example, seeStudy Effect of Initial Condition Uncertainty on Model Response.

  • Addition of noise to simulated data — If you want to include the influence of additive disturbances, specify theAddNoiseoption astrue. For an example, seeStudy Effect of Additive Disturbance on Response Uncertainty.

Output Arguments

collapse all

Simulated response, returned as a cell array ofN+1 elements.y{1}contains the nominal response forsys. The remaining elements contain the simulated response for theNperturbed realizations.

The command performs multiple simulations using different values of the uncertain parameters of the model, and different realizations of additive noise and simulation initial conditions. Thus, the simulated responses are all identical ifsysdoes not contain parameter covariance information and you do not specify additive noise and covariance values for initial states inopt.

Estimated standard deviation of simulated response, returned as aniddataobject. The standard deviation is computed as the sample standard deviation of theyensemble:

y _ s d = 1 N i = 2 N + 1 ( y { 1 } y { i } ) 2

Herey{1}是名义上的响应sys, andy{i}(i = 2:N+1) are the simulated responses for theNperturbed realizations ofsys.

More About

collapse all

Generating Perturbations of Identified Model

The software generatesNperturbations of the identified modelsysand then simulates the response of each of these perturbations. The parameters of the perturbed realizations ofsysare consistent with the parameter covariance of the original modelsys. The parameter covariance ofsysgives information about the distribution of the parameters. However, for some parameter values, the resulting perturbed systems can be unstable. To reduce the probability of generation of unrealistic systems, the software prescales the parameter covariance.

IfΔpis the parameter covariance for the parameterspofsys,然后模拟outputf(p+Δp)of a perturbed model as a first-order approximation is:

f ( p + Δ p ) = f ( p ) + f p Δ p

Thesimsdcommand first scalesΔpby a scaling factors(approximately 0.1%) to generate perturbed systems with parameters(p+sΔp). The command then computesf(p+sΔp), the simulated response of these perturbed systems. Where,

f ( p + s Δ p ) = f ( p ) + s f p Δ p

The command then computes the simulated responsef(p+Δp)as:

f ( p + Δ p ) = f ( p ) + 1 s ( f ( p + s Δ p ) f ( p ) )

Note

This scaling is not applied to the free delays ofidprocoridtfmodels.

If you specify theAddNoiseoption ofsimsdOptionsastrue, the software adds different realizations of the noise sequence to the noise-free responses of the perturbed system. The realizations of the noise sequence are consistent with the noise component of the model.

For state-space models, if you specify the covariance of initial state values inX0Covarianceoption ofsimsdOptions, different realizations of the initial states are used to simulate each perturbed model. Initial states are drawn from a Gaussian distribution with meanInitialConditionand covarianceX0Covariance.

Version History

Introduced before R2006a

Baidu
map