Documentation Center 
Simulate approximate solution of diagonaldrift HWV and GBM processes
[Paths, Times, Z] = OBJ.simBySolution(NPERIODS)
[Paths, Times, Z] = OBJ.simBySolution(NPERIODS, 'Name1', Value1,'Name2', Value2, ...)
The simBySolution method simulates NTRIALS sample paths of NVARS correlated state variables, driven by NBROWNS Brownian motion sources of risk over NPERIODS consecutive observation periods, approximating continuoustime HullWhite/Vasicek (HWV) and geometric Brownian motion (GBM) shortrate models by an approximation of the closedform solution.
Consider a separable, vectorvalued HWV model of the form:
(1812) 
where:
X is an NVARSby1 state vector of process variables.
S is an NVARSbyNVARS matrix of mean reversion speeds (the rate of mean reversion).
L is an NVARSby1 vector of mean reversion levels (longrun mean or level).
V is an NVARSbyNBROWNS instantaneous volatility rate matrix.
W is an NBROWNSby1 Brownian motion vector.
or a separable, vectorvalued GBM model of the form:
(1813) 
where:
X_{t} is an NVARSby1 state vector of process variables.
μ is an NVARSbyNVARS generalized expected instantaneous rate of return matrix.
V is an NVARSbyNBROWNS instantaneous volatility rate matrix.
dW_{t} is an NBROWNSby1 Brownian motion vector.
The simBySolution method simulates the state vector X_{t} using an approximation of the closedform solution of diagonaldrift models.
When evaluating the expressions, simBySolution assumes that all model parameters are piecewiseconstant over each simulation period.
In general, this is not the exact solution to the models, because the probability distributions of the simulated and true state vectors are identical only for piecewiseconstant parameters.
When parameters are piecewiseconstant over each observation period, the simulated process is exact for the observation times at which X_{t} is sampled.
OBJ  HullWhite/Vasicek (HWV) or geometric Brownian motion (GBM) model. 
NPERIODS  Positive scalar integer number of simulation periods. The value of this argument determines the number of rows of the simulated output series. 
Specify optional input arguments as variablelength lists of matching parameter name/value pairs: 'Name1', Value1, 'Name2', Value2, ... and so on. The following rules apply when specifying parametername pairs:
Specify the parameter name as a character string, followed by its corresponding parameter value.
You can specify parameter name/value pairs in any order.
Parameter names are case insensitive.
You can specify unambiguous partial string matches.
Valid parameter names are:
NTRIALS  Positive scalar integer number of simulated trials (sample paths) of NPERIODS observations each. If you do not specify a value for this argument, the default is 1, indicating a single path of correlated state variables. 
DeltaTime  Scalar or NPERIODSby1 column vector of positive time increments between observations. DeltaTime represents the familiar dt found in stochastic differential equations, and determines the times at which simBySolution reports the simulated paths of the output state variables. If you do not specify a value for this argument, the default is 1. 
NSTEPS  Positive scalar integer number of intermediate time steps within each time increment dt (specified as DeltaTime). simBySolution partitions each time increment dt into NSTEPS subintervals of length dt/NSTEPS, and refines the simulation by evaluating the simulated state vector at NSTEPS  1 intermediate points. Although simBySolution does not report the output state vector at these intermediate points, the refinement improves accuracy by allowing the simulation to more closely approximate the underlying continuoustime process. If you do not specify a value for NSTEPS, the default is 1, indicating no intermediate evaluation. 
Antithetic  Scalar logical flag that indicates whether antithetic sampling
is used to generate the Gaussian random variates that drive the Brownian
motion vector (Wiener processes). When Antithetic is TRUE (logical 1), simBySolution performs
sampling such that all primary and antithetic paths are simulated
and stored in successive matching pairs:

Z  Direct specification of the dependent random noise process
used to generate the Brownian motion vector (Wiener process) that
drives the simulation. Specify this argument as a function, or as
an (NPERIODS * NSTEPS)byNBROWNSbyNTRIALS array
of dependent random variates. If you specify Z as
a function, it must return an NBROWNSby1 column
vector, and you must call it with two inputs:

StorePaths  Scalar logical flag that indicates how simBySolution stores the output array Paths and returns it to the caller. If StorePaths is TRUE(the default value) or is unspecified, simBySolution returns Paths as a threedimensional time series array. If StorePaths is FALSE (logical 0), simBySolution returns the Paths output array as an empty matrix. 
Processes  Function or cell array of functions that indicates a sequence
of endofperiod processes or state vector adjustments of the form simBySolution applies processing functions at the end of each observation period. These functions must accept the current observation time t and the current state vector X_{t}, and return a state vector that may be an adjustment to the input state. If you specify more than one processing function, simBySolution invokes the functions in the order in which they appear in the cell array. You can use this argument to specify boundary conditions, prevent negative prices, accumulate statistics, plot graphs, and more. If you do not specify a processing function, simBySolution makes no adjustments and performs no processing. 
Paths  (NPERIODS + 1)byNVARSbyNTRIALS threedimensional time series array, consisting of simulated paths of correlated state variables. For a given trial, each row of Paths is the transpose of the state vector X_{t} at time t. When the input flag StorePaths = FALSE, simBySolution returns Paths as an empty matrix. 
Times  (NPERIODS + 1)by1 column vector of observation times associated with the simulated paths. Each element of Times is associated with the corresponding row of Paths. 
Z  (NPERIODS * NSTEPS)byNBROWNSbyNTRIALS threedimensional time series array of dependent random variates used to generate the Brownian motion vector (Wiener processes) that drive the simulation. 
Implementing Multidimensional Equity Market Models, Implementation 6: Using GBM Simulation Methods
AitSahalia, Y., "Testing ContinuousTime Models of the Spot Interest Rate," The Review of Financial Studies, Spring 1996, Vol. 9, No. 2, pp. 385–426.
AitSahalia, Y., "Transition Densities for Interest Rate and Other Nonlinear Diffusions," The Journal of Finance, Vol. 54, No. 4, August 1999.
Glasserman, P., Monte Carlo Methods in Financial Engineering, New York: SpringerVerlag, 2004.
Hull, J. C., Options, Futures, and Other Derivatives, 5th ed. Englewood Cliffs, NJ: Prentice Hall, 2002.
Johnson, N. L., S. Kotz, and N. Balakrishnan, Continuous Univariate Distributions, Vol. 2, 2nd ed. New York: John Wiley & Sons, 1995.
Shreve, S. E., Stochastic Calculus for Finance II: ContinuousTime Models, New York: SpringerVerlag, 2004.