Changeset 1058
- Timestamp:
- 06/07/10 22:36:56 (15 years ago)
- Files:
-
- 7 modified
Legend:
- Unmodified
- Added
- Removed
-
applications/bdmtoolbox/tutorial/userguide/memds_example.m
r1057 r1058 12 12 %M=simulator(DS2); 13 13 14 M. ch014 M.DS_dt_ 15 15 %M.DS_dt_Data -
library/bdm/base/bdmbase.cpp
r1021 r1058 530 530 531 531 void DS::from_setting ( const Setting &set ) { 532 RV rv; 533 if( UI::get( rv, set, "drv", UI::optional ) ) 534 set_drv ( rv, RV() ); 532 UI::get( Drv, set, "drv", UI::optional ); 533 UI::get(log_level, set, "log_level",UI::optional); 535 534 } 536 535 … … 538 537 if( !Drv._dsize() && dtsize > 0 ) 539 538 { 540 RV *r = newRV();539 Drv = RV(); 541 540 for ( int i = 0; i < dtsize; i++ ) { 542 r->add ( RV ( "ch" + num2str ( i ), 1, 0 ) ); 543 } 544 set_drv ( *r, RV() ); 545 delete r; 541 Drv.add ( RV("", dtsize )); 542 } 546 543 } 547 544 } -
library/bdm/base/bdmbase.h
r1055 r1058 1162 1162 1163 1163 The DataSource has three main data interaction structures: 1164 \li input, \f$ u_t \f$, 1165 \li output \f$ d_t \f$, 1166 In simulators, d_t may contain "hidden" variables as well. 1164 \li input, \f$ u_t \f$, which are described via RVs in attribute \c urv 1165 \li observations \f$ d_t \f$, which are described in \c drv 1166 In simulators, dt may contain "hidden" variables as well. 1167 1167 1168 */ 1168 1169 … … 1234 1235 } 1235 1236 1236 //! set random variables 1237 virtual void set_drv ( const RV &drv, const RV &urv) { 1238 Drv = drv; 1239 Urv = urv; 1240 } 1241 1237 /*! 1238 \code 1239 drv = bdm::RV::from_setting // decription of observed data 1240 urv = bdm::RV::from_setting // decription of input data 1241 log_level = "logdt,logut" // when set, both the simulated data and the inputs are stored to the logger 1242 // By default both are on. It makes sense to switch them off for MemDS where the data are already stored. 1243 \endcode 1244 */ 1242 1245 void from_setting ( const Setting &set ); 1243 1246 -
library/bdm/base/datasources.cpp
r1057 r1058 23 23 } 24 24 25 void MemDS::set_drv ( const RV &drv ) {26 bdm_assert_debug ( drv._dsize() == Data.rows(), "MemDS::set_rvs incompatible drv" );27 DS::set_drv ( drv, RV() );28 }29 30 25 void MemDS::from_setting ( const Setting &set ) { 31 26 DS::from_setting ( set ); … … 40 35 void MemDS::validate() 41 36 { 37 if (Urv._dsize()>0){ 38 bdm_error ( "MemDS::urv is not supported" ); 39 } 42 40 dtsize = Data.rows(); 43 41 utsize = 0; -
library/bdm/base/datasources.h
r1056 r1058 20 20 namespace bdm { 21 21 /*! 22 * \brief Memory storage of off-line data column-wise 23 24 The data are stored in an internal matrix \c Data . E ach column of Data corresponds to one discrete time observation \f$t\f$. Access to this matrix is via indices \c rowid.25 26 The data can be loaded from a file. 22 * \brief Memory storage of off-line data column-wise (used mostly in C++) 23 24 The data are stored in an internal matrix \c Data . E 25 ach column of Data corresponds to one discrete time observation \f$t\f$. 26 27 27 */ 28 28 class MemDS : public DS { … … 49 49 void getdata ( vec &dt, const ivec &indices ); 50 50 51 void set_drv ( const RV &drv );52 53 void set_drv ( const RV &drv, const RV &urv )54 {55 if (urv._dsize()>0){56 bdm_error ( "MemDS::urv is not supported" );57 } else {58 DS::set_drv(drv,urv);59 }60 61 }62 63 51 void write ( const vec &ut ) { 64 52 if (ut.size()>0){ … … 77 65 /*! Create object from the following structure 78 66 \code 79 DS.class = "MemDS";80 D S.Data = (...); % Data matrix or data vector67 class = "MemDS"; 68 Data = (...); % Data matrix or data vector 81 69 --- optional --- 82 DS.drv = {class="RV"; ...} % Identification how rows of the matrix Data will be known to others 83 DS.time = 0; % Index of the first column to user_info, 84 DS.log_level = "logdt,logut"; % switches to log (or not log) dt or ut 85 } 70 time = 0; % Index of the first column to user_info, 71 ... % fields from bdm::DS::from_setting 86 72 \endcode 87 73 … … 104 90 UIREGISTER ( MemDS ); 105 91 106 /*! Pseudovirtual class for reading data from files92 /*! \brief Pseudovirtual class for reading data from files 107 93 108 94 */ … … 111 97 string filename; 112 98 public: 99 /*! reads what DS::from_setting 100 \code 101 filename = 'data_file.ext'; // name of the file where the data sare stored 102 the same as #bdm::DS 103 \endcode 104 */ 113 105 void from_setting ( const Setting & set ); 114 106 }; … … 144 136 /*! 145 137 * \brief CSV file data storage 138 146 139 The constructor creates \c Data matrix from the records in a CSV file \c fname. The orientation can be of two types: 147 140 1. \c BY_COL which is default - the data are stored in columns; one column per time \f$t\f$, one row per data item. … … 201 194 dt = zeros ( iepdf->dimension() ); 202 195 dtsize = dt.length(); 203 set_drv ( iepdf->_rv(), RV());196 Drv = iepdf->_rv(); 204 197 utsize = 0; 205 198 } … … 251 244 \code 252 245 class = "PdfDS"; 253 pdf = {class="pdf_offspring", ...}; // pdf to simulate246 pdf = bdm::pdf::from_setting; // pdf to simulate, any offspring of pdf 254 247 --- optional --- 255 init_rv = {class="RV",names=...};// define what rv to initialize - typically delayed values!248 init_rv = bdm::RV::from_setting; // define what rv to initialize - typically delayed values! 256 249 init_values = [...]; // vector of initial values corresponding to init_rv 257 250 \endcode … … 267 260 // input is what in not in Yrv 268 261 Urv = rgrv0.subt ( Yrv ); 269 set_drv ( concat(Yrv,Urv), Urv);262 Drv= concat(Yrv,Urv); 270 263 // connect input and output to rvc 271 264 ut2rgr.set_connection ( ipdf->_rvc(), Urv ); -
library/bdm/mex/mex_datasource.h
r1056 r1058 52 52 53 53 if (Drv._dsize()!=dtsize){ 54 RV def ( ( const char* ) set["varname"], dtsize ); 55 set_drv ( def, Urv ); 54 Drv=RV( ( const char* ) set["varname"], dtsize ); 56 55 } 57 56 column = 0; -
library/bdm/stat/exp_family.h
r1033 r1058 682 682 /*! \brief Random Walk with vector Beta distribution 683 683 Using simple assignment 684 \f{ align}685 \alpha &= rvc / k + \beta_c \\686 \beta &= (1-rvc) / k + \beta_c \\687 \f{ align}684 \f{eqnarray} 685 \alpha &=& rvc / k + \beta_c \\ 686 \beta &= &(1-rvc) / k + \beta_c \\ 687 \f{eqnarray} 688 688 for each element of alpha and beta, mean value = rvc, variance = (k+1)*mean*mean; 689 689