Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

simByEuler

Euler simulation of stochastic differential equations (SDEs)

Synopsis

[Paths, Times, Z] = simByEuler(MDL, NPERIODS)

[Paths, Times, Z] = simByEuler(MDL, NPERIODS, 'Name1', Value1, 'Name2', Value2, ...)

Classes

All classes in the SDE Class Hierarchy.

Description

This method simulates any vector-valued SDE of the form

dXt=F(t,Xt)dt+G(t,Xt)dWt

where:

  • X is an NVARS-by-1 state vector of process variables (for example, short rates or equity prices) to simulate.

  • W is an NBROWNS-by-1 Brownian motion vector.

  • F is an NVARS-by-1 vector-valued drift-rate function.

  • G is an NVARS-by-NBROWNS matrix-valued diffusion-rate function.

simByEuler simulates NTRIALS sample paths of NVARS correlated state variables driven by NBROWNS Brownian motion sources of risk over NPERIODS consecutive observation periods, using the Euler approach to approximate continuous-time stochastic processes.

Input Arguments

MDLStochastic differential equation object created with the sdeddo constructor.
NPERIODSPositive scalar integer number of simulation periods. The value of NPERIODS determines the number of rows of the simulated output series.

Optional Input Arguments

Specify optional inputs as matching parameter name/value pairs as follows:

  • Specify the parameter name as a character vector, followed by its corresponding value.

  • You can specify parameter name/value pairs in any order.

  • Parameter names are case insensitive.

  • You can specify unambiguous partial character vector 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 NPERIODS-by-1 column vector of positive time increments between observations. DeltaTime represents the familiar dt found in stochastic differential equations, and determines the times at which the simulated paths of the output state variables are reported. 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). The simByEuler method 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 simByEuler 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 continuous-time 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 simByEuler uses antithetic sampling to generate the Gaussian random variates that drive the Brownian motion vector (Wiener processes).

When Antithetic is TRUE (logical 1), simByEuler performs sampling such that all primary and antithetic paths are simulated and stored in successive matching pairs:

  • Odd trials (1,3,5,...) correspond to the primary Gaussian paths.

  • Even trials (2,4,6,...) are the matching antithetic paths of each pair derived by negating the Gaussian draws of the corresponding primary (odd) trial.

If you specify Antithetic to be any value other than TRUE, simByEuler assumes that it is FALSE (logical 0) by default, and does not perform antithetic sampling. When you specify an input noise process (see Z), simByEuler ignores the value of Antithetic.

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)-by-NBROWNS-by-NTRIALS three-dimensional array of dependent random variates. If you specify Z as a function, it must return an NBROWNS-by-1 column vector, and you must call it with two inputs:

  • A real-valued scalar observation time t.

  • An NVARS-by-1 state vector Xt.

If you do not specify a value for Z, simByEuler generates correlated Gaussian variates based on the Correlation member of the SDE object.

StorePaths

Scalar logical flag that indicates how the output array Paths is stored and returned to the caller. If StorePaths is TRUE (the default value) or is unspecified, simByEuler returns Paths as a three-dimensional time series array.

If StorePaths is FALSE (logical 0), simByEuler returns the Paths output array as an empty matrix.

Processes

Function or cell array of functions that indicates a sequence of end-of-period processes or state vector adjustments of the form

Xt=P(t,Xt)

simByEuler applies processing functions at the end of each observation period. These functions must accept the current observation time t and the current state vector Xt, and return a state vector that may be an adjustment to the input state.

If you specify more than one processing function, simByEuler 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, simByEuler makes no adjustments and performs no processing.

Output Arguments

Paths(NPERIODS + 1)-by-NVARS-by-NTRIALS three-dimensional 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 Xt at time t. When the input flag StorePaths = FALSE, simByEuler returns Paths as an empty matrix.
Times (NPERIODS + 1)-by-1 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)-by-NBROWNS-by-NTRIALS three-dimensional time series array of dependent random variates used to generate the Brownian motion vector (Wiener processes) that drive the simulation.

Examples

Implementing Multidimensional Equity Market Models, Implementation 5: Using the simByEuler Method

Algorithms

  • This simulation engine provides a discrete-time approximation of the underlying generalized continuous-time process. The simulation is derived directly from the stochastic differential equation of motion. Thus, the discrete-time process approaches the true continuous-time process only as DeltaTime approaches zero.

  • The input argument Z allows you to directly specify the noise-generation process. This process takes precedence over the Correlation parameter of thesde object and the value of the Antithetic input flag. If you do not specify a value for Z, simByEuler generates correlated Gaussian variates, with or without antithetic sampling as requested.

  • The end-of-period Processes argument allows you to terminate a given trial early. At the end of each time step, simByEuler tests the state vector Xt for an all-NaN condition. Thus, to signal an early termination of a given trial, all elements of the state vector Xt must be NaN. This test enables a user-defined Processes function to signal early termination of a trial, and offers significant performance benefits in some situations (for example, pricing down-and-out barrier options).

References

Ait-Sahalia, Y. “Testing Continuous-Time Models of the Spot Interest Rate.” The Review of Financial Studies, Spring 1996, Vol. 9, No. 2, pp. 385–426.

Ait-Sahalia, 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, Springer-Verlag, 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: Continuous-Time Models. New York: Springer-Verlag, 2004.

Introduced in R2008a

Was this topic helpful?