Show
Ignore:
Timestamp:
10/19/09 22:24:45 (15 years ago)
Author:
smidl
Message:

Compilation and minor extensions

Files:
1 modified

Legend:

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

    r660 r665  
    244244                double& _nu()  {return nu;} 
    245245                const double& _nu() const {return nu;} 
     246                const int & _dimx() const {return dimx;} 
    246247                /*! Create Gauss-inverse-Wishart density  
    247248                \f[ f(rv) = GiW(V,\nu) \f] 
     
    250251                class = 'egiw'; 
    251252                V     = [];               // square matrix 
     253                dV    = [];               // vector of diagonal of V (when V not given) 
    252254                nu    = [];               // scalar \nu ((almost) degrees of freedom) 
    253255                                                                  // when missing, it will be computed to obtain proper pdf 
     
    260262                void from_setting (const Setting &set) { 
    261263                        epdf::from_setting(set); 
    262                         if (!UI::get (nu, set, "nu", UI::compulsory)) {nu=-1;} 
    263264                        UI::get (dimx, set, "dimx", UI::compulsory); 
     265                        if (!UI::get (nu, set, "nu", UI::optional)) {nu=-1;} 
    264266                        mat V; 
    265                         UI::get (V, set, "V", UI::compulsory); 
    266                         set_parameters (dimx, V, nu); 
     267                        if (!UI::get (V, set, "V", UI::optional)){ 
     268                                vec dV; 
     269                                UI::get (dV, set, "dV", UI::compulsory); 
     270                                set_parameters (dimx, ldmat(dV), nu); 
     271                                 
     272                        } else { 
     273                                set_parameters (dimx, V, nu); 
     274                        } 
     275                } 
     276                void validate(){ 
     277                        // check sizes, rvs etc. 
    267278                } 
    268279                //!@} 
     
    594605 
    595606                double evallog (const vec &val) const  { 
    596                         if (any (val < low) && any (val > high)) {return inf;} 
     607                        if (any (val < low) && any (val > high)) {return -inf;} 
    597608                        else return lnk; 
    598609                } 
     
    632643UIREGISTER(euni); 
    633644 
     645//! Uniform density with conditional mean value 
     646class mguni : public mpdf_internal<euni>{ 
     647        //! function of the mean value 
     648        shared_ptr<fnc> mean; 
     649        //! distance from mean to both sides 
     650        vec delta; 
     651        public: 
     652                void condition(const vec &cond){ 
     653                        vec mea=mean->eval(cond); 
     654                        iepdf.set_parameters(mea-delta,mea+delta); 
     655                } 
     656                //! load from 
     657                void from_setting(const Setting &set){ 
     658                        mpdf::from_setting(set); //reads rv and rvc 
     659                        UI::get(delta,set,"delta",UI::compulsory); 
     660                        mean = UI::build<fnc>(set,"mean",UI::compulsory); 
     661                         
     662                        iepdf.set_parameters(-delta,delta); 
     663                        dimc = mean->dimensionc(); 
     664                        validate(); 
     665                } 
     666}; 
     667UIREGISTER(mguni); 
    634668/*! 
    635669 \brief Normal distributed linear function with linear function of mean value;