Finance - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Mathematics : Finance : Stochastic Processes : Finance/SampleValues

Finance

  

SampleValues

  

generate sample value(s) for the specified expression

 

Calling Sequence

Parameters

Options

Description

Examples

References

Compatibility

Calling Sequence

SampleValues(pathfunction, pathgenerator, opts)

SampleValues(pathfunction, process, timegrid, opts)

SampleValues(pathfunction, process, timeinterval, opts)

SampleValues(expression, opts)

Parameters

pathfunction

-

procedure; path function

pathgenerator

-

path generator data structure; path generator

process

-

one- or multi-dimensional stochastic process, or list or vector of one-dimensional stochastic processes

timegrid

-

range or time grid data structure; time grid

timeinterval

-

range; time interval

expression

-

algebraic expression; expression whose value is to be generated

opts

-

(optional) equation(s) of the form option = value where option is one of replications or timesteps; specify options for the SampleValues command

Options

• 

replications = posint -- This option specifies the number of replications of the sample path. By default, only one replication of the sample path is generated.

• 

timesteps = posint -- This option specifies the number of time steps. This option is ignored if an explicit time grid is specified. By default, only one time step is used.

Description

• 

The SampleValues(pathfunction, pathgenerator, opts) calling sequence computes a Monte Carlo estimate of pathfunction using sample paths generated by pathgenerator. The procedure consists of the following steps:

– 

Generate a replication of the sample path using the specified path generator and store these values as a Maple Array, for example A. In the case of a one-dimensional process A is a one-dimensional array of size n, where n is the number of points in the time grid (the number of time steps plus one). In the case of a multi-dimensional process, A is a two-dimensional array of size m,n, where m is the dimension of the underlying stochastic process and n is the same as in the one-dimensional case.

– 

Compute the value pathfunctionA.

– 

Repeat the above two steps the specified number of times (see the replications option).

• 

The SampleValues(pathfunction, process, timegrid, opts) and SampleValues(pathfunction, process, timeinterval, opts) calling sequences first construct the corresponding path generator and then perform the same computations as above.

• 

The parameter timeinterval must be of type range T0..T1, where T0 and T1 are non-negative constants such that T0<T1.

• 

When the ExpectedValue(pathfunction, process, timeinterval, opts) calling sequence is used, the uniform time grid between T0 and T1 (with time steps dt&equals;T1T0timesteps) is generated.

  

Note that if 0<T0, the value at T0 will be simulated using a single step of the default discretization method and hence can suffer from a significant discretization bias. Increasing the number of time steps will refine the grid between T0 and T1, but will have no effect on the value at T0. To reduce the bias, use a time interval of the form 0..T1.

• 

The SampleValues(expression, opts) calling sequence attempts to extract all the stochastic variables involved in expression and generate the corresponding path generator and path function using the specified number of time steps. In particular, SampleValues will extract all time instances involved in expression and adjust them so that they belong to the grid.

  

All stochastic variables involved in expression should be of the form Xt, where t is some expression. If X is multi-dimensional stochastic, then the individual components of X can be accessed using the notation Xti.

Examples

withFinance&colon;

Here is a simple one-dimensional stochastic process.

XWienerProcess

X:=_W

(1)

SSampleValues&ExponentialE;X3&comma;timesteps&equals;100&comma;replications&equals;104

S:= 1 .. 10000 ArrayData Type: float8Storage: rectangularOrder: C_order

(2)

Statistics:-DataSummaryS&comma;output&equals;mean&comma;standarddeviation

4.41583032222043&comma;14.7026267487629

(3)

Use a Maple procedure to compute the same expression.

TTimeGrid3&comma;100&colon;

GXPathGeneratorX&comma;T&colon;

SSampleValuesA&rarr;&ExponentialE;A101&comma;GX&comma;replications&equals;104

S:= 1 .. 10000 ArrayData Type: float8Storage: rectangularOrder: C_order

(4)

Statistics:-DataSummaryS&comma;output&equals;mean&comma;standarddeviation

4.33299075633332&comma;18.2389408161531

(5)

Here is an example involving a multivariate stochastic process.

&Sigma;1.0&comma;0.5&verbar;0.5&comma;1.0

&Sigma;:=1.00.50.51.0

(6)

WWienerProcess&Sigma;

W:=_W0

(7)

SSampleValuesmaxW31&comma;W31&comma;timesteps&equals;100&comma;replications&equals;104

S:= 1 .. 10000 ArrayData Type: float8Storage: rectangularOrder: C_order

(8)

Statistics:-DataSummaryS&comma;output&equals;mean&comma;standarddeviation

0.0106647008230180&comma;1.72908152039724

(9)

Here is the same computation using Maple procedures.

TTimeGrid3&comma;100&colon;

GWPathGeneratorW&comma;T&colon;

SSampleValuesA&rarr;maxA1101&comma;A2101&comma;GW&comma;replications&equals;105

S:= 1 .. 100000 ArrayData Type: float8Storage: rectangularOrder: C_order

(10)

Statistics:-DataSummaryS&comma;output&equals;mean&comma;kurtosis&comma;standarddeviation

0.698559577951287&comma;3.01709634240065&comma;1.58748095181072

(11)

Use a two-dimensional Ito process using two one-dimensional projections and a given covariance matrix.

XGeometricBrownianMotion100.0&comma;0.05&comma;0.3&comma;t

X:=_X1

(12)

YGeometricBrownianMotion100.0&comma;0.07&comma;0.2&comma;t

Y:=_X2

(13)

&Sigma;1&verbar;0.5&comma;0.5&verbar;1

&Sigma;:=10.50.51

(14)

ZItoProcessX&comma;Y&comma;&Sigma;

Z:=_X3

(15)

DriftZt

0.05_X3t10.07_X3t2

(16)

DiffusionZt

0.3_X3t10.15_X3t10.10_X3t20.2_X3t2

(17)

SampleValuesmaxX1Y1&comma;0&comma;timesteps&equals;100&comma;replications&equals;104

1 .. 10000 ArrayData Type: float8Storage: rectangularOrder: C_order

(18)

SampleValuesmaxZ11Z12&comma;0&comma;timesteps&equals;100&comma;replications&equals;104

1 .. 10000 ArrayData Type: float8Storage: rectangularOrder: C_order

(19)

References

  

Glasserman, P., Monte Carlo Methods in Financial Engineering. New York: Springer-Verlag, 2004.

  

Hull, J., Options, Futures, and Other Derivatives, 5th. edition. Upper Saddle River, New Jersey: Prentice Hall, 2003.

  

Kloeden, P., and Platen, E., Numerical Solution of Stochastic Differential Equations, New York: Springer-Verlag, 1999.

Compatibility

• 

The Finance[SampleValues] command was introduced in Maple 15.

• 

For more information on Maple 15 changes, see Updates in Maple 15.

See Also

Finance[BrownianMotion]

Finance[CEVProcess]

Finance[DeterministicProcess]

Finance[Diffusion]

Finance[Drift]

Finance[ExpectedValue]

Finance[GaussianShortRateProcess]

Finance[GeometricBrownianMotion]

Finance[HestonProcess]

Finance[OrnsteinUhlenbeckProcess]

Finance[PathPlot]

Finance[SamplePath]

Finance[SquareRootDiffusion]

Finance[StochasticProcesses]

Finance[ValueAtRisk]

Finance[WienerProcess]

 


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam