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 00026 #ifndef martingale_randomvariables_h 00027 #define martingale_randomvariables_h 00028 00029 #include "TypedefsMacros.h" 00030 #include "RandomObject.h" // base class 00031 #include "ControlledRandomVariable.h" // base class 00032 00033 00034 MTGL_BEGIN_NAMESPACE(Martingale) 00035 00036 00037 00042 /******************************************************************************* 00043 00044 SOME CONCRETE RANDOMVECTORS 00045 00046 *******************************************************************************/ 00047 00048 00050 class StandardNormalVector : public RandomVector { 00051 00052 public: 00053 00054 StandardNormalVector(int d) : RandomVector(d) {} 00055 00056 virtual ~StandardNormalVector(){} 00057 00059 RealVector nextValue(); 00060 00061 }; // end StandardNormalVector 00062 00063 00064 00065 00066 00067 /******************************************************************************* 00068 00069 Standard Normal Variable 00070 00071 *******************************************************************************/ 00072 00076 class StandardNormalVariable : public ControlledRandomVariable { 00077 00078 public: 00079 00080 // sample - control variate pair 00081 RealVector nextValue(); 00082 00083 Real getControlVariateMean() { return 0; } 00084 00085 StandardNormalVariable() { setBeta(); } 00086 00087 }; // end StandardNormalVariable 00088 00089 00090 00091 00092 00093 /******************************************************************************* 00094 00095 Empirical Random Variable 00096 00097 *******************************************************************************/ 00098 00099 00115 class EmpiricalRandomVariable : public RandomVariable { 00116 00117 int sampleSize; // number of data points 00118 Real* dataSet; // array of data points 00119 00120 public: 00121 00124 int getSampleSize() const { return sampleSize; } 00125 00128 Real* getDataSet() const { return dataSet; } 00129 00130 00136 EmpiricalRandomVariable(Real* data_set, int sample_size) : 00137 sampleSize(sample_size), 00138 dataSet(data_set) 00139 { } 00140 00141 00145 Real nextValue(); 00146 00147 00148 // TEST PROGRAM 00149 00153 static void test(int n); 00154 00155 00156 }; // end EmpiricalRandomvariable 00157 00158 00159 00160 00161 MTGL_END_NAMESPACE(Martingale) 00162 00163 00164 #endif