Changeset 634
- Timestamp:
- 09/27/09 00:57:54 (15 years ago)
- Location:
- library
- Files:
-
- 1 added
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
library/bdm/stat/exp_family.h
r629 r634 297 297 //!@} 298 298 299 //! using sampling procedure from wikipedia 299 300 vec sample() const { 300 bdm_error ("Not implemented"); 301 return vec(); 301 vec y(beta.length()); 302 for (int i=0; i<beta.length(); i++){ 303 GamRNG.setup(beta(i),1); 304 y(i)=GamRNG.sample(); 305 } 306 return y/sum(y); 302 307 } 303 308 304 309 vec mean() const {return beta / sum (beta);}; 305 vec variance() const {double gamma = sum (beta); return elem_mult (beta, ( beta + 1)) / (gamma* (gamma + 1));}310 vec variance() const {double gamma = sum (beta); return elem_mult (beta, (gamma-beta)) / (gamma*gamma* (gamma + 1));} 306 311 //! In this instance, val is ... 307 312 double evallog_nn (const vec &val) const { … … 321 326 //!access function 322 327 vec& _beta() {return beta;} 323 //!Set internal parameters 324 }; 328 /*! configuration structure 329 \code 330 class = 'eDirich'; 331 beta = []; //parametr beta 332 \endcode 333 */ 334 void from_setting(const Setting &set){ 335 epdf::from_setting(set); 336 UI::get(beta,set, "beta", UI::compulsory); 337 validate(); 338 } 339 void validate() { 340 //check rv 341 dim = beta.length(); 342 } 343 }; 344 UIREGISTER(eDirich); 325 345 326 346 //! \brief Estimator for Multinomial density -
library/tests/epdf_test.cpp
r547 r634 75 75 CHECK_CLOSE ( observed, actual, 0.1 ); 76 76 } 77 78 TEST(test_dirich){ 79 epdf_harness::test_config ( "edirich.cfg" ); 80 }