Show
Ignore:
Timestamp:
11/25/09 18:02:21 (14 years ago)
Author:
mido
Message:

the rest of h to cpp movements, with exception of from_setting and validate to avoid conflicts with Sarka

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • library/bdm/stat/exp_family.cpp

    r737 r739  
    279279        M = iLsub * Lpsi; 
    280280        R = ldR.to_mat()  ; 
     281} 
     282 
     283void egiw::log_register ( bdm::logger& L, const string& prefix ) { 
     284        if ( log_level == 3 ) { 
     285                root::log_register ( L, prefix ); 
     286                logrec->ids.set_length ( 2 ); 
     287                int th_dim = dimension() - dimx * ( dimx + 1 ) / 2; 
     288                logrec->ids ( 0 ) = L.add_vector ( RV ( "", th_dim ), prefix + logrec->L.prefix_sep() + "mean" ); 
     289                logrec->ids ( 1 ) = L.add_vector ( RV ( "", th_dim * th_dim ), prefix + logrec->L.prefix_sep() + "variance" ); 
     290        } else { 
     291                epdf::log_register ( L, prefix ); 
     292        } 
     293} 
     294 
     295void egiw::log_write() const { 
     296        if ( log_level == 3 ) { 
     297                mat M; 
     298                ldmat Lam; 
     299                ldmat Vz; 
     300                factorize ( M, Vz, Lam ); 
     301                logrec->L.log_vector ( logrec->ids ( 0 ), est_theta() ); 
     302                logrec->L.log_vector ( logrec->ids ( 1 ), cvectorize ( est_theta_cov().to_mat() ) ); 
     303        } else { 
     304                epdf::log_write(); 
     305        } 
     306 
     307} 
     308 
     309void multiBM::bayes ( const vec &yt, const vec &cond ) { 
     310        if ( frg < 1.0 ) { 
     311                beta *= frg; 
     312                last_lognc = est.lognc(); 
     313        } 
     314        beta += yt; 
     315        if ( evalll ) { 
     316                ll = est.lognc() - last_lognc; 
     317        } 
     318} 
     319 
     320double multiBM::logpred ( const vec &yt ) const { 
     321        eDirich pred ( est ); 
     322        vec &beta = pred._beta(); 
     323 
     324        double lll; 
     325        if ( frg < 1.0 ) { 
     326                beta *= frg; 
     327                lll = pred.lognc(); 
     328        } else if ( evalll ) { 
     329                lll = last_lognc; 
     330        } else { 
     331                lll = pred.lognc(); 
     332        } 
     333 
     334        beta += yt; 
     335        return pred.lognc() - lll; 
     336} 
     337void multiBM::flatten ( const BMEF* B ) { 
     338        const multiBM* E = dynamic_cast<const multiBM*> ( B ); 
     339        // sum(beta) should be equal to sum(B.beta) 
     340        const vec &Eb = E->beta;//const_cast<multiBM*> ( E )->_beta(); 
     341        beta *= ( sum ( Eb ) / sum ( beta ) ); 
     342        if ( evalll ) { 
     343                last_lognc = est.lognc(); 
     344        } 
    281345} 
    282346 
     
    462526} 
    463527 
     528void mlstudent::condition ( const vec &cond ) { 
     529        if ( cond.length() > 0 ) { 
     530                iepdf._mu() = A * cond + mu_const; 
     531        } else { 
     532                iepdf._mu() =  mu_const; 
     533        } 
     534        double zeta; 
     535        //ugly hack! 
     536        if ( ( cond.length() + 1 ) == Lambda.rows() ) { 
     537                zeta = Lambda.invqform ( concat ( cond, vec_1 ( 1.0 ) ) ); 
     538        } else { 
     539                zeta = Lambda.invqform ( cond ); 
     540        } 
     541        _R = Re; 
     542        _R *= ( 1 + zeta );// / ( nu ); << nu is in Re!!!!!! 
     543} 
     544 
     545void eEmp::qbounds ( vec &lb, vec &ub, double perc ) const { 
     546        // lb in inf so than it will be pushed below; 
     547        lb.set_size ( dim ); 
     548        ub.set_size ( dim ); 
     549        lb = std::numeric_limits<double>::infinity(); 
     550        ub = -std::numeric_limits<double>::infinity(); 
     551        int j; 
     552        for ( int i = 0; i < n; i++ ) { 
     553                for ( j = 0; j < dim; j++ ) { 
     554                        if ( samples ( i ) ( j ) < lb ( j ) ) { 
     555                                lb ( j ) = samples ( i ) ( j ); 
     556                        } 
     557                        if ( samples ( i ) ( j ) > ub ( j ) ) { 
     558                                ub ( j ) = samples ( i ) ( j ); 
     559                        } 
     560                } 
     561        } 
     562} 
     563 
     564 
    464565};