Logo Search packages:      
Sourcecode: quantlib version File versions

stochasticprocess.hpp

Go to the documentation of this file.
/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */

/*
 Copyright (C) 2003 Ferdinando Ametrano
 Copyright (C) 2001, 2002, 2003 Sadruddin Rejeb
 Copyright (C) 2004, 2005 StatPro Italia srl

 This file is part of QuantLib, a free-software/open-source library
 for financial quantitative analysts and developers - http://quantlib.org/

 QuantLib is free software: you can redistribute it and/or modify it
 under the terms of the QuantLib license.  You should have received a
 copy of the license along with this program; if not, please email
 <quantlib-dev@lists.sf.net>. The license is also available online at
 <http://quantlib.org/reference/license.html>.

 This program is distributed in the hope that it will be useful, but WITHOUT
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 FOR A PARTICULAR PURPOSE.  See the license for more details.
*/

/*! \file stochasticprocess.hpp
    \brief stochastic processes
*/

#ifndef quantlib_stochastic_process_hpp
#define quantlib_stochastic_process_hpp

#include <ql/date.hpp>
#include <ql/Patterns/observable.hpp>

namespace QuantLib {

    //! Stochastic process class
    /*! This class describes a stochastic process governed by
        \f[
            dx_t = \mu(t, x_t)dt + \sigma(t, x_t)dW_t.
        \f]
    */
00040     class StochasticProcess : public Observer, public Observable {
      public:
        //! discretization of a stochastic process over a given time interval
00043         class discretization {
          public:
            virtual ~discretization() {}
            virtual Real expectation(const StochasticProcess&,
                                     Time t0, Real x0, Time dt) const = 0;
            virtual Real variance(const StochasticProcess&,
                                  Time t0, Real x0, Time dt) const = 0;
        };
        virtual ~StochasticProcess() {}

        //! \name Stochastic process interface
        //@{
        //! returns the initial value of the state variable
        virtual Real x0() const = 0;
        //! returns the drift part of the equation, i.e. \f$ \mu(t, x_t) \f$
        virtual Real drift(Time t, Real x) const = 0;
        /*! \brief returns the diffusion part of the equation, i.e.
            \f$ \sigma(t, x_t) \f$
        */
        virtual Real diffusion(Time t, Real x) const = 0;
        /*! returns the expectation
            \f$ E(x_{t_0 + \Delta t} | x_{t_0} = x_0) \f$
            of the process after a time interval \f$ \Delta t \f$
            according to the given discretization. This method can be
            overridden in derived classes which want to hard-code a
            particular discretization.
        */
        virtual Real expectation(Time t0, Real x0, Time dt) const;
        /*! returns the variance
            \f$ V(x_{t_0 + \Delta t} | x_{t_0} = x_0) \f$
            of the process after a time interval \f$ \Delta t \f$
            according to the given discretization. This method can be
            overridden in derived classes which want to hard-code a
            particular discretization.
        */
        virtual Real variance(Time t0, Real x0, Time dt) const;
        /*! applies a change to the asset value. By default; it
            returns \f$ x + \Delta x \f$.
        */
        virtual Real evolve(Real change, Real currentValue) const;
        //@}

        //! \name utilities
        //@{
        /*! returns the time value corresponding to the given date
            in the reference system of the stochastic process.

            \note As a number of processes might not need this
                  functionality, a default implementation is given
                  which raises an exception.
        */
        virtual Time time(const Date&) const;
        //@}

        //! \name Observer interface
        //@{
        void update();
        //@}
      protected:
        StochasticProcess();
        StochasticProcess(const boost::shared_ptr<discretization>&);
        boost::shared_ptr<discretization> discretization_;
    };


    //! Euler discretization for stochastic processes
00109     class EulerDiscretization : public StochasticProcess::discretization {
      public:
        /*! Returns an approximation of the expected value defined as
            \f$ x_0 + \mu(t_0, x_0) \Delta t \f$.
        */
        Real expectation(const StochasticProcess&,
                         Time t0, Real x0, Time dt) const;
        /*! Returns an approximation of the variance defined as
            \f$ \sigma(t_0, x_0)^2 \Delta t \f$.
        */
        Real variance(const StochasticProcess&,
                      Time t0, Real x0, Time dt) const;
    };

}


#endif

Generated by  Doxygen 1.6.0   Back to index