|
STK++ 1.0
|
00001 /*--------------------------------------------------------------------*/ 00002 /* Copyright (C) 2004-2007 Serge Iovleff 00003 00004 This program is free software; you can redistribute it and/or modify 00005 it under the terms of the GNU Lesser General Public License as 00006 published by the Free Software Foundation; either version 2 of the 00007 License, or (at your option) any later version. 00008 00009 This program is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 GNU Lesser General Public License for more details. 00013 00014 You should have received a copy of the GNU Lesser General Public 00015 License along with this program; if not, write to the 00016 Free Software Foundation, Inc., 00017 59 Temple Place, 00018 Suite 330, 00019 Boston, MA 02111-1307 00020 USA 00021 00022 Contact : Serge.Iovleff@stkpp.org 00023 */ 00024 00025 /* 00026 * Project: stkpp::STatistiK::Law 00027 * Purpose: Interface base class for all univariate probabilities laws. 00028 * Author: Serge Iovleff, serge.iovleff@stkpp.org 00029 **/ 00030 00036 #ifndef STK_LAW_ITUNIVARIATE_H 00037 #define STK_LAW_ITUNIVARIATE_H 00038 00039 // RandBase header 00040 #include "STK_Law_ILawBase.h" 00041 #include "../../Sdk/include/STK_ITContainer2D.h" 00042 00043 namespace STK 00044 { 00045 00046 namespace Law 00047 { 00066 template <class TYPE> 00067 class ITUnivariate : public ILawBase 00068 { 00069 protected: 00073 ITUnivariate(String const& name) : ILawBase(name) 00074 { ;} 00075 00076 public: 00078 virtual ~ITUnivariate() { ;} 00079 00084 template< class Container1D> 00085 void rand1D( ITContainer1D< TYPE, Container1D>& A) const 00086 { 00087 // get dimensions 00088 const Integer first = A.first(), last = A.last(); 00089 // generate and set random variables 00090 for (Integer i=first; i<=last; i++) A[i] = rand(); 00091 } 00092 00097 template < class TContainer2D> 00098 void rand2D( ITContainer2D< TYPE, TContainer2D>& A) const 00099 { 00100 // get dimensions 00101 const Integer firstRow = A.firstRow(), lastRow = A.lastRow(); 00102 const Integer firstCol = A.firstCol(), lastCol = A.lastCol(); 00103 // generate and set random variables 00104 for (Integer j=firstCol; j<=lastCol; j++) 00105 for (Integer i=firstRow; i<=lastRow; i++) 00106 A(i, j) = rand(); 00107 } 00108 00109 private: 00116 virtual Real cdf(Real const& t) const =0; 00117 00123 virtual Real pdf(TYPE const& x) const =0; 00124 00130 virtual Real lpdf(TYPE const& x) const = 0; 00134 virtual TYPE rand() const =0; 00135 00141 virtual Real icdf(Real const& p) const=0; 00142 }; 00143 00144 } // namespace Law 00145 00146 } // namespace STK 00147 00148 #endif /*STK_LAW_ITUNIVARIATE_H*/