SPSens includes functions to compile and run sensitivity and simulation algorithms from Matlab using the MEX interface. This can be helpful while initially creating the model as it allows for rapid analysis within Matlab and easy changes. An example file, '
In order to use this, MEX must first be properly configured on the machine. Plenty of documentation to introduce the MEX interface and to assist in its configuration can be found at http://www.mathworks.com/support/tech-notes/1600/1605.html.
Once MEX is configured properly and SPSens has been unpacked, one can build sensitivity and simulation programs for the problem at the Matlab command interface by taking the following steps:
Create the problem and name it prob_\<probname>.c where \<probname> is whatever file name is desired. Make sure its directory is in the current path (can do this manually by using the command: addpath path_to_problem)
Change working directory to SPSens_path/mex, or alternatively add the full directory path to the Matlab path.
Build the sensitivity analysis program by calling:
Build_spsmx_sens(probname,optional_argument)
If successful this creates the function 'spsSens_\<prob_name>' in the current directory.
Build the stochastic simulation programs by calling:
Build_spsmx_sim(probname,optional_argument)
If successful this creates the functions 'spsSim_\<prob_name>' and 'spsSP_\<prob_name>' in the current directory.
Notes:
Once it has been built, sensitivity with respect to whichever set of parameters is desired is computed using the 'GetStochSens' function. Statistics of the estimates (point estimates of the sensitivity values and their confidence intervals) can be computed easily with the function 'GetSensitivityResultStats'. See help in matlab for both of these, along with the example file demonstrating use of each of the methods.
After building, generate a sample path using the 'GetSamplePath' wrapper function. Check the help and the example file demonstrating proper use of the method.
After building, generate an ensemble of trajectories sampled at a specified vector of times using the 'GetStochSim' function. Statistics of the estimates (point estimates of the expected value at each time point, confidence intervals of the point estimates, estimates of the variance) can be computed easily with the function 'GetSimulationResultStats'. See help in Matlab and the example file demonstrating proper use of these functions.