Function File: [Paths, Times, Z] = simByEuler (SDE, Periods, OptionName, OptionValue, …)

Simulates a stochastic differential equation (SDE) using Euler timestepping.

  • Variable: SDE An sde object.
  • Variable: Periods Number of simulation periods.

A list of options recognized by simByEuler are given below:

  • NTRIALS - Number of sample paths to use in simulation. If unspecified, the default is 1.
  • DeltaTime - Scalar or NPERIODS-dimensional vector of timesteps. If unspecified, the default is 1.
  • NSTEPS - Number of intervals to subdivide each period in. If unspecified, the default is 1.
  • Antithetic - Logical flag specifying if antithetic variates, a variance reduction technique, should be used. This value is ignored when Z is specified (see below). If unspecified, the default is false.
  • Z - (NPERIODS * NSTEPS)-by-NBROWNS-by-NTRIALS three-dimensional array of random samples to use in the simulation. Alternatively, a function returning an NBROWNS-dimensional column vector can be specified, with inputs:
    • A real-valued observation time t;
    • An NVARS-dimensional state vector X_t.
  • StorePaths - Logical flag specifying whether or not to store sample paths. If false, Paths is returned as an empty matrix. If unspecified, the default is true.
  • Processes - Function or cell-array of functions specifying state adjustments of the form X_t = P(t, X_t-) at the end of each period (X_t- is the limit of X_s as s goes to from the right). If a single function is specified, it is applied to the end of each period. If a cell-array is specified, the functions are all applied at the end of each period in the order that they appear. If unspecified, no adjustments are made at the end of periods.
  • Broadcast - Logical flag specifying whether or not to use broadcasting to speed up computation. If false, broadcasting is disabled. If unspecified, the default is true.

The outputs are described below:

  • Variable: Paths (NPERIODS + 1)-by-NVARS-by-NTRIALS array consisting of the simulated paths.
  • Variable: Times (NPERIODS + 1)-dimensional column vector of observation corresponding to the paths.
  • Variable: Z (NPERIODS * NSTEPS)-by-NBROWNS-by-NTRIALS array of variates used to generate the process.

The method will attempt to use a fast broadcasting implementation whenever possible. This is possible when the following requirements are met:

  • The methods Drift(t, X) (resp. Diffusion(t, X)) of the SDE object return an NVARS-by-1-by-NTRIALS (resp. NVARS-by-NBROWNS-by-NTRIALS) array when X is an NVARS-by-1-by-NTRIALS array.
  • If the user specifies Z as a function Z(t, X), it returns an NBROWNS-by-NTRIALS matrix when X is an NVARS-by-1-by-NTRIALS array.
  • If the user specifies Processes, each function P(t, X) returns an NVARS-by-1-NTRIALS array when X is an NVARS-by-1-by-NTRIALS array.

If any of the above conditions are violated, the fast broadcasting implementation is not used.

An example is provided in the documentation of @sde/simulate.

See also: sde, @sde/simulate.

Package: financial