325 | | void log_register ( bdm::logger& L, const string& prefix ) { |
326 | | if ( log_level == 3 ) { |
327 | | root::log_register ( L, prefix ); |
328 | | logrec->ids.set_length ( 2 ); |
329 | | int th_dim = dimension() - dimx * ( dimx + 1 ) / 2; |
330 | | logrec->ids ( 0 ) = L.add_vector ( RV ( "", th_dim ), prefix + logrec->L.prefix_sep() + "mean" ); |
331 | | logrec->ids ( 1 ) = L.add_vector ( RV ( "", th_dim * th_dim ), prefix + logrec->L.prefix_sep() + "variance" ); |
332 | | } else { |
333 | | epdf::log_register ( L, prefix ); |
334 | | } |
335 | | } |
336 | | void log_write() const { |
337 | | if ( log_level == 3 ) { |
338 | | mat M; |
339 | | ldmat Lam; |
340 | | ldmat Vz; |
341 | | factorize ( M, Vz, Lam ); |
342 | | logrec->L.log_vector ( logrec->ids ( 0 ), est_theta() ); |
343 | | logrec->L.log_vector ( logrec->ids ( 1 ), cvectorize ( est_theta_cov().to_mat() ) ); |
344 | | } else { |
345 | | epdf::log_write(); |
346 | | } |
347 | | |
348 | | } |
| 325 | void log_register ( bdm::logger& L, const string& prefix ); |
| 326 | |
| 327 | void log_write() const; |
528 | | void bayes ( const vec &yt, const vec &cond = empty_vec ) { |
529 | | if ( frg < 1.0 ) { |
530 | | beta *= frg; |
531 | | last_lognc = est.lognc(); |
532 | | } |
533 | | beta += yt; |
534 | | if ( evalll ) { |
535 | | ll = est.lognc() - last_lognc; |
536 | | } |
537 | | } |
538 | | double logpred ( const vec &yt ) const { |
539 | | eDirich pred ( est ); |
540 | | vec &beta = pred._beta(); |
541 | | |
542 | | double lll; |
543 | | if ( frg < 1.0 ) { |
544 | | beta *= frg; |
545 | | lll = pred.lognc(); |
546 | | } else if ( evalll ) { |
547 | | lll = last_lognc; |
548 | | } else { |
549 | | lll = pred.lognc(); |
550 | | } |
551 | | |
552 | | beta += yt; |
553 | | return pred.lognc() - lll; |
554 | | } |
555 | | void flatten ( const BMEF* B ) { |
556 | | const multiBM* E = dynamic_cast<const multiBM*> ( B ); |
557 | | // sum(beta) should be equal to sum(B.beta) |
558 | | const vec &Eb = E->beta;//const_cast<multiBM*> ( E )->_beta(); |
559 | | beta *= ( sum ( Eb ) / sum ( beta ) ); |
560 | | if ( evalll ) { |
561 | | last_lognc = est.lognc(); |
562 | | } |
563 | | } |
| 507 | void bayes ( const vec &yt, const vec &cond = empty_vec ); |
| 508 | |
| 509 | double logpred ( const vec &yt ) const; |
| 510 | |
| 511 | void flatten ( const BMEF* B ); |
| 512 | |
973 | | void condition ( const vec &cond ) { |
974 | | if ( cond.length() > 0 ) { |
975 | | iepdf._mu() = A * cond + mu_const; |
976 | | } else { |
977 | | iepdf._mu() = mu_const; |
978 | | } |
979 | | double zeta; |
980 | | //ugly hack! |
981 | | if ( ( cond.length() + 1 ) == Lambda.rows() ) { |
982 | | zeta = Lambda.invqform ( concat ( cond, vec_1 ( 1.0 ) ) ); |
983 | | } else { |
984 | | zeta = Lambda.invqform ( cond ); |
985 | | } |
986 | | _R = Re; |
987 | | _R *= ( 1 + zeta );// / ( nu ); << nu is in Re!!!!!! |
988 | | }; |
| 922 | |
| 923 | void condition ( const vec &cond ); |
1528 | | void qbounds ( vec &lb, vec &ub, double perc = 0.95 ) const { |
1529 | | // lb in inf so than it will be pushed below; |
1530 | | lb.set_size ( dim ); |
1531 | | ub.set_size ( dim ); |
1532 | | lb = std::numeric_limits<double>::infinity(); |
1533 | | ub = -std::numeric_limits<double>::infinity(); |
1534 | | int j; |
1535 | | for ( int i = 0; i < n; i++ ) { |
1536 | | for ( j = 0; j < dim; j++ ) { |
1537 | | if ( samples ( i ) ( j ) < lb ( j ) ) { |
1538 | | lb ( j ) = samples ( i ) ( j ); |
1539 | | } |
1540 | | if ( samples ( i ) ( j ) > ub ( j ) ) { |
1541 | | ub ( j ) = samples ( i ) ( j ); |
1542 | | } |
1543 | | } |
1544 | | } |
1545 | | } |
| 1463 | void qbounds ( vec &lb, vec &ub, double perc = 0.95 ) const; |