Numerical Methods in Computational Finance. Daniel J. Duffy

Читать онлайн книгу.

Numerical Methods in Computational Finance - Daniel J. Duffy


Скачать книгу
(0.0554, 0.0559), (0.0556, 0.0559), (0.0558, 0.0559), (0.05589, 0.0559).

      For a more complete discussion of Boost odeint, see Duffy (2018).

      We complete our discussion of finite difference methods for (3.10). The full problem is (3.11); (3.12) is a coupled system of equations, and it can be solved in different ways. The most effective approach at this stage is to use a production third-party ODE solver in C++.

      We have seen what scalar and vector ODEs are. Now we consider matrix ODEs.

      The Boost odeint library can be used to solve matrix ODEs, for example:

      where A, B and Y are n times n matrices.

      (3.26)upper Y left-parenthesis t right-parenthesis equals e Superscript italic upper A t Baseline upper C e Superscript italic upper B t Baseline comma where upper Y left-parenthesis 0 right-parenthesis equals upper C comma and upper C is a given matrix period

      A special case is when:

      (3.27)StartLayout 1st Row 1st Column Blank 2nd Column upper B equals 0 left-parenthesis zero matrix right-parenthesis 2nd Row 1st Column Blank 2nd Column upper C equals upper I left-parenthesis identity matrix right-parenthesis in which case we have the solution which is the 3rd Row 1st Column Blank 2nd Column italic exponential of a matrix colon EndLayout

      (3.28)upper Y left-parenthesis t right-parenthesis equals e Superscript italic upper A t Baseline period

      (3.29)StartLayout Enlarged left-brace 1st Row StartFraction italic d upper Y Over italic d t EndFraction equals italic upper A upper Y 2nd Row upper Y left-parenthesis 0 right-parenthesis equals upper C period EndLayout

      where C is a given matrix.

      We model this system by the following C++ class:

       namespace ublas = boost::numeric::ublas; using value_type = double; using state_type = boost::numeric::ublas::matrix<value_type>; class MatrixOde { private: // dB/dt = A*B, B(0) = C; ublas::matrix<value_type> A_; ublas::matrix<value_type> C_; public: MatrixOde(const ublas::matrix<value_type>& A, const ublas::matrix<value_type>& IC) : A_(A), C_(IC) {} void operator()(const state_type &x , state_type &dxdt, double t ) const { for( std::size_t i=0 ; i < x.size1();++i ) { for( std::size_t j=0 ; j < x.size2(); ++j ) { dxdt(i, j) = 0.0; for (std::size_t k = 0; k < x.size2(); ++k) { dxdt(i, j) += A_(i,k)*x(k,j); } } } } };

       S1: Series methods (for example, truncating the infinite Taylor series representation for the exponential).

       S2: Padé rational approximant. This entails approximating the exponential by a special kind of rational function.

       S3: Polynomial methods using the Cayley–Hamilton method.

       S4: Inverse Laplace transform.

       S5: Matrix decomposition methods.

       S6: Splitting methods.

      3.7.1 Transition Rate Matrices and Continuous Time Markov Chains

      An interesting application of matrices and matrix ODEs is to the modelling of credit rating applications (Wilmott (2006), vol. 2, pp. 665–73). To this end, we define a so-called transition matrix P, which is a table whose elements are probabilities representing migrations from one credit rating to another credit rating. For example, a company having a B rating has a probability 0.07 of getting a BB rating in a small period of time. More generally, we are interested in continuous-time transitions between states using Markov chains, and we have the following Kolmogorov forward equation:

      (3.30)StartFraction italic d upper P left-parenthesis t comma t Superscript prime Baseline right-parenthesis Over italic d t EndFraction equals upper P left-parenthesis t comma t Superscript prime Baseline right-parenthesis upper Q

      where t equals current time t prime equals future time and upper P left-parenthesis t comma t right-parenthesis equals upper I identical-to unit matrix unit matrix and upper Q equals left-parenthesis q Subscript italic i j Baseline right-parenthesis comma 1 less-than-or-equal-to i comma j less-than-or-equal-to n is the transition rate matrix having the following properties:

StartLayout 1st Row 1st Column Blank 2nd Column Number 1 period 0 less-than-or-equal-to minus q Subscript italic i i Baseline less-than infinity 2nd Row 1st Column Blank 2nd Column Number 2 period 0 less-than-or-equal-to minus q Subscript italic i j Baseline comma i not-equals j 3rd Row 1st Column Blank 2nd Column 3 period sigma-summation Underscript j Endscripts q Subscript italic i j Baseline equals 0 left-parenthesis upper R o w sums right-parenthesis for-all i equals 1 comma ellipsis comma n period EndLayout

      The Kolmogorov backward equation is:

      (3.31)StartFraction italic d upper P left-parenthesis t comma t Superscript prime Baseline right-parenthesis Over italic d t EndFraction equals minus italic upper Q upper P left-parenthesis t comma t Superscript prime Baseline right-parenthesis period

      The objective is to compute the transition rate matrix Q (that is, states that are in one-to-one correspondence with the integers).

      In the case of countable space, the Kolmogorov forward equation is:

      (3.32)StartFraction partial-differential upper P Subscript italic i j Baseline Over partial-differential t EndFraction left-parenthesis s semicolon t right-parenthesis equals sigma-summation Underscript k Endscripts upper P Subscript italic i k Baseline left-parenthesis s semicolon t right-parenthesis upper Q Subscript italic k j Baseline left-parenthesis t right-parenthesis

      where Q(t)


Скачать книгу