Changeset 283 for bdm/stat/libEF.h

Show
Ignore:
Timestamp:
02/24/09 14:14:01 (15 years ago)
Author:
smidl
Message:

get rid of BMcond + adaptation in doprava/

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • bdm/stat/libEF.h

    r281 r283  
    9494//      virtual void flatten ( double nu0 ) {it_error ( "Not implemented" );} 
    9595 
    96         BMEF* _copy_ ( bool changerv=false ) {it_error ( "function _copy_ not implemented for this BM" ); return NULL;}; 
     96        BMEF* _copy_ ( bool changerv=false ) const {it_error ( "function _copy_ not implemented for this BM" ); return NULL;}; 
    9797}; 
    9898 
     
    348348 \f] 
    349349 
     350Vector \f$\beta\f$ has different meaning (in fact it is 1/beta as used in definition of iG) 
     351 
    350352 Inverse Gamma can be converted to Gamma using \f[ 
    351353 x\sim iG(a,b) => 1/x\sim G(a,1/b) 
     
    354356 */ 
    355357 
    356 class eigamma : public eEF { 
    357 protected: 
    358         //!internal egamma 
    359         egamma eg; 
    360         //! Vector \f$\alpha\f$ 
    361         vec α 
    362         //! Vector \f$\beta\f$ (in fact it is 1/beta as used in definition of iG) 
    363         vec β 
     358class eigamma : public egamma { 
     359protected: 
    364360public : 
    365361        //! \name Constructors 
    366         //!@{ 
    367         eigamma ( ) :eEF ( ), eg(),alpha ( eg._alpha() ), beta ( eg._beta() ) {}; 
    368         eigamma ( const vec &a, const vec &b ) :eEF ( ), eg(),alpha ( eg._alpha() ), beta ( eg._beta() ) {eg.set_parameters ( a,b );}; 
    369         void set_parameters ( const vec &a, const vec &b ) {eg.set_parameters ( a,b );}; 
    370         //!@} 
    371  
    372         vec sample() const {return 1.0/eg.sample();}; 
    373         //! TODO: is it used anywhere? 
    374 //      mat sample ( int N ) const; 
    375         double evallog ( const vec &val ) const {return eg.evallog ( val );}; 
    376         double lognc () const {return eg.lognc();}; 
     362        //! All constructors are inherited 
     363        //!@{ 
     364        //!@} 
     365 
     366        vec sample() const {return 1.0/egamma::sample();}; 
    377367        //! Returns poiter to alpha and beta. Potentially dangerous: use with care! 
    378368        vec mean() const {return elem_div ( beta,alpha-1 );} 
    379369        vec variance() const {vec mea=mean(); return elem_div ( elem_mult ( mea,mea ),alpha-2 );} 
    380         vec& _alpha() {return alpha;} 
    381         vec& _beta() {return beta;} 
    382370}; 
    383371/* 
     
    490478        mgnorm() :mu ( epdf._mu() ) {ep=&epdf;} 
    491479        //!set mean function 
    492         void set_parameters ( fnc* g0, const sq_T &R0 ) {g=g0; epdf.set_parameters ( zeros ( g->_dimy() ), R0 );} 
     480        void set_parameters ( fnc* g0, const sq_T &R0 ) {g=g0; epdf.set_parameters ( zeros ( g->dimension() ), R0 );} 
    493481        void condition ( const vec &cond ) {mu=g->eval ( cond );}; 
    494482}; 
     
    686674 
    687675        //! Set samples and weights 
    688         void set_parameters ( const vec &w0, const epdf* pdf0 ); 
     676        void set_statistics ( const vec &w0, const epdf* pdf0 ); 
     677        //! Set samples and weights 
     678        void set_statistics ( const epdf* pdf0 , int n ) {set_statistics ( ones ( n ) /n,pdf0 );}; 
    689679        //! Set sample 
    690680        void set_samples ( const epdf* pdf0 ); 
    691681        //! Set sample 
    692         void set_n ( int n0, bool copy=true ) {n=n0; w.set_size ( n0,copy );samples.set_size ( n0,copy );}; 
     682        void set_parameters ( int n0, bool copy=true ) {n=n0; w.set_size ( n0,copy );samples.set_size ( n0,copy );}; 
    693683        //! Potentially dangerous, use with care. 
    694684        vec& _w()  {return w;}; 
     
    700690        const Array<vec>& _samples() const {return samples;}; 
    701691        //! Function performs resampling, i.e. removal of low-weight samples and duplication of high-weight samples such that the new samples represent the same density. 
    702         ivec resample ( RESAMPLING_METHOD method = SYSTEMATIC ); 
     692        ivec resample ( RESAMPLING_METHOD method=SYSTEMATIC ); 
    703693        //! inherited operation : NOT implemneted 
    704694        vec sample() const {it_error ( "Not implemented" );return 0;} 
     
    714704                for ( int i=0;i<n;i++ ) {pom+=pow ( samples ( i ),2 ) *w ( i );} 
    715705                return pom-pow ( mean(),2 ); 
     706        } 
     707        //! For this class, qbounds are minimum and maximum value of the population! 
     708        void qbounds ( vec &lb, vec &ub, double perc=0.95 ) const { 
     709                // lb in inf so than it will be pushed below; 
     710                lb.set_size(dim); 
     711                ub.set_size(dim); 
     712                lb = std::numeric_limits<double>::infinity(); 
     713                ub = -std::numeric_limits<double>::infinity(); 
     714                int j; 
     715                for ( int i=0;i<n;i++ ) { 
     716                        for ( j=0;j<dim; j++ ) { 
     717                                if ( samples ( i ) ( j ) <lb ( j ) ) {lb ( j ) =samples ( i ) ( j );} 
     718                                if ( samples ( i ) ( j ) >ub ( j ) ) {ub ( j ) =samples ( i ) ( j );} 
     719                        } 
     720                } 
    716721        } 
    717722};