Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

ControlledRandomVariable.h

Go to the documentation of this file.
00001 /* WARANTY NOTICE AND COPYRIGHT
00002 This program is free software; you can redistribute it and/or
00003 modify it under the terms of the GNU General Public License
00004 as published by the Free Software Foundation; either version 2
00005 of the License, or (at your option) any later version.
00006 
00007 This program is distributed in the hope that it will be useful,
00008 but WITHOUT ANY WARRANTY; without even the implied warranty of
00009 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00010 GNU General Public License for more details.
00011 
00012 You should have received a copy of the GNU General Public License
00013 along with this program; if not, write to the Free Software
00014 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00015 
00016 Copyright (C) Michael J. Meyer
00017 
00018 matmjm@mindspring.com
00019 spyqqqdia@yahoo.com
00020 
00021 */
00022 
00023 
00024 
00025 #ifndef martingale_controlled_randomvariable_h    
00026 #define martingale_controlled_randomvariable_h 
00027 
00028 #include "TypedefsMacros.h"
00029 #include "RandomObject.h"                 // base class
00030 #include "Matrix.h"                       // typedef problem in forward declarations
00031 
00032 
00033 MTGL_BEGIN_NAMESPACE(Martingale)
00034 
00035 
00036 // dependencies: 
00037 // class RealVector;
00038 
00039 
00040 
00052 class ControlledRandomVariable : private RandomVector {
00053     
00054     // number of samples used to compute the {@link #betaCoefficient}.
00055     static const int nBeta=2000;
00056         Real beta;
00057     
00058 public:   
00059         
00060 
00061 // ACCESSORS
00062 
00063         Real getBeta() const { return beta; }
00064         
00071         void setBeta() { beta=betaCoefficient(); }
00072         
00073         
00074 // CONSTRUCTOR: WE HAVE A DEFAULT CONSTRUCTOR
00075         
00079         ControlledRandomVariable();
00080 
00081         
00082 // RANDOM DEVIATE - CONTROL VARIATE PAIR, CONTROL VARIATE MEAN
00083         
00087     virtual RealVector nextValue() = 0;
00088 
00089     
00094     virtual Real getControlVariateMean() = 0;
00095         
00096         
00097         
00098 // AUXILLIARY CLASS
00099         
00103      class ControlledVariable : public RandomVariable {
00104                 
00105                ControlledRandomVariable* XC;
00106         
00107          public:
00108                  
00109                Real nextValue();
00110         
00111                ControlledVariable(ControlledRandomVariable* xc) : XC(xc) { }
00112       };
00113         
00114                         
00118     RandomVariable* controlled();
00119                 
00120 
00121  
00122 // MEAN
00123     
00124     
00131     Real expectation(int N);
00132     
00133 
00134     
00141     Real expectation(int N, string message);
00142     
00143     
00144 
00145 // TEST OF CONTROL VARIATE MEAN FORMULA
00146  
00147  
00154      void controlVariateMeanTest(int N);
00155      
00156      
00157 // BETA COEFFICIENT, CORRELATION WITH CONTROL VARIATE
00158 
00159      
00164     Real betaCoefficient();    
00165     
00166      
00167      
00177       Real correlationWithControlVariate(int N);
00178         
00179  
00180 }; //end ControlledRandomVariable
00181 
00182 
00183 
00184 MTGL_END_NAMESPACE(Martingale)
00185 
00186 #endif
00187  

Generated on Mon Sep 22 02:16:32 2003 for Libor-Library by doxygen1.3-rc3