Welcome to THETAWIKI. If you like to create or edit a page please make sure to login or register an account. All registered users please make sure to provide a valid email address.

Matlab Stochastic Processes

From ThetaWiki
Jump to: navigation, search

Stochastic processes in Matlab

It is easy to define stochastic processes in Matlab-M code and call them from ThetaML. The best way is to include a Matlab stochastic process object:

The Stepping Object

The complex stepping object can be invoked implicitly, if specified in the configuration, or explicitely with the call @matlab : <stepper> command. For the called case the object allows much more sophisticated interactions.

The stepper object must implement the following methods. In Matlab versions prior to 2008b, the object can also be a struct, with function valued fields for each method.

Method Description

Init() Reset the model to its initial state Step(dt) Proceed the model by time dt. Throw random numbers if required SetValues(name, value) Set a state variable to the new value GetValues(name) Get the value of a variable computed by this model GetModelVariables() Give a list of imported and exported variables for this model

The general form of the function header for pre-2008b version consists of the method definitions and a construction from a Parameters object. This type of object interaction only works for Monte-Carlo evaluations. The Parameters structure is guaranteed to contain at least one field: NoOfScenarios with the number pathes as value.

function model = ModelName(Parameters)
 
model.Step                 = @Step;
model.SetValues            = @SetValues;
model.GetValues            = @GetValues;
model.SetModelpoint        = @SetModelpoint;
model.GetModelVariables    = @GetModelVariables;
model.Init                 = @Init;
 
if nargin > 0
        ... Construct the object ...
else
        ... Construct an empty object for import variable inspection ...
end

It is of crucial importance for the correctness for the the generated code, that the internal state of the object can be inspected as relevant. All variables that can be used to infer stochastic properties of the variables values must be made explicit. Additionally, variables can be marked as beeing part of the minimal Markov state, one which is sufficient to make best guesses for the future state. A visibility setting can hide a variable from explicit usage in ThetaML. However, the generated code will still make of its value for its numercial algorithm.

The model variable(s) returned by the GetModelVariables method must be a structure with fields for each relevant variable. Each field must have the following sub fields for each variable.

Description A human readable description of the the variables role in the model

Visibility

Either 'Import','Export' or 'Private' depending on whether the variable is imported or exported, or hidden.

IsState

For Export variables this boolean flag indicates, whether the variable is part of the minimal Markov state which is required to make a best guess for the future value of all exported variables.

Size / Type

This flag indicates the dimension of a model variable, excluding the scenario dimension. For non-numeric types, this field can be set to 'Object' or 'String'. Import variables can also have their Size set to 'File' which indicates that the value must be the URL of an existing file.