Note: This page has been translated by MathWorks. Please click here

To view all translated materials including this page, select Japan from the country navigator on the bottom of this page.

To view all translated materials including this page, select Japan from the country navigator on the bottom of this page.

Convert time series arrays to functions of time and state

`F = ts2func(Array)`

```
F = ts2func(Array, 'Name1', Value1, 'Name2', Value2,
...)
```

The `ts2func`

function encapsulates a time
series array associated with a vector of real-valued observation times
within a MATLAB^{®} function suitable for Monte Carlo simulation
of an `NVARS`

-by-`1`

state vector *X _{t}*.

`Array` | Time series array to encapsulate within a callable function
of time and state. `Array` may be a vector, 2-dimensional
matrix, or three-dimensional array. |

Specify optional input arguments as variable-length lists of
matching parameter name/value pairs: `'Name1'`

, `Value1`

, `'Name2'`

, `Value2`

,
... and so on. The following rules apply when specifying parameter-name
pairs:

Specify the parameter name as a character vector, 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 character vector matches.

Valid parameter names are:

`Times` | Vector of monotonically increasing observation times
associated with the time series input array |

`TimeDimension` | Positive scalar integer that specifies which dimension
of the input time series array |

`StateDimension` | Positive scalar integer that specifies which dimension
of the input time series array `Array` not already
assigned to `TimeDimension` ). |

`Deterministic` | A scalar, logical flag to indicate whether the output
function is a deterministic function of time alone. If |

`F` | Callable function If
the optional input argument |

When you specify

`Array`

as a trivial scalar or a vector (row or column),`ts2func`

assumes that it represents a univariate time series.`F`

returns an array with one fewer dimension than the input time series array`Array`

with which`F`

is associated. Thus, when`Array`

is a vector, a 2-dimensional matrix, or a three-dimensional array,`F`

returns a scalar, vector, or 2-dimensional matrix, respectively.When the scalar time

*t*at which`ts2func`

evaluates the function`F`

does not coincide with an observation time in`Times`

,`F`

performs a zero-order-hold interpolation. The only exception is if*t*precedes the first element of`Times`

, in which case*F(t)*=*F(Times(1))*.To support Monte Carlo simulation methods, the output function

`F`

returns an`NVARS`

-by-`1`

column vector or a 2-dimensional matrix with`NVARS`

rows.The output function

`F`

is always a deterministic function of time,*F(t)*, and may always be called with a single input regardless of the`Deterministic`

flag. The distinction is that when`Deterministic`

is false, the function`F`

may also be called with a second input, an`NVARS`

-by-`1`

state vector*X(t)*, which is a placeholder and ignored. While*F(t)*and*F(t,X)*produce identical results, the former specifically indicates that the function is a deterministic function of time, and may offer significant performance benefits in some situations.

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.

Was this topic helpful?