Show
Ignore:
Timestamp:
09/16/09 22:52:42 (15 years ago)
Author:
smidl
Message:

doc - new pattern for from_setting for pdfs

Files:
1 modified

Legend:

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

    r620 r621  
    134134                enorm (const vec &mu, const sq_T &R) {set_parameters (mu, R);} 
    135135                void set_parameters (const vec &mu, const sq_T &R); 
     136                /*! Create Normal density 
     137                \f[ f(rv) = N(\mu, R) \f] 
     138                from structure 
     139                \code 
     140                class = 'enorm<ldmat>', (OR) 'enorm<chmat>', (OR) 'enorm<fsqmat>'; 
     141                mu    = [];                  // mean value 
     142                R     = [];                  // variance, square matrix of appropriate dimension 
     143                \endcode 
     144                */ 
    136145                void from_setting (const Setting &root); 
    137146                void validate() { 
     
    247256                double& _nu()  {return nu;} 
    248257                const double& _nu() const {return nu;} 
     258                /*! Create Gauss-inverse-Wishart density  
     259                \f[ f(rv) = GiW(V,\nu) \f] 
     260                from structure 
     261                \code 
     262                class = 'egiw'; 
     263                V     = [];               // square matrix 
     264                nu    = [];               // scalar \nu ((almost) degrees of freedom) 
     265                                                                  // when missing, it will be computed to obtain proper pdf 
     266                dimx  = [];               // dimension of the wishart part 
     267                rv = RV({'name'})         // description of RV 
     268                rvc = RV({'name'})        // description of RV in condition 
     269                \endcode 
     270                */ 
     271                 
    249272                void from_setting (const Setting &set) { 
    250                         UI::get (nu, set, "nu", UI::compulsory); 
     273                        epdf::from_setting(set); 
     274                        if (!UI::get (nu, set, "nu", UI::compulsory)) {nu=-1;} 
    251275                        UI::get (dimx, set, "dimx", UI::compulsory); 
    252276                        mat V; 
    253277                        UI::get (V, set, "V", UI::compulsory); 
    254278                        set_parameters (dimx, V, nu); 
    255                         shared_ptr<RV> rv = UI::build<RV> (set, "rv", UI::compulsory); 
    256                         set_rv (*rv); 
    257279                } 
    258280                //!@} 
     
    401423                vec variance() const {return elem_div (alpha, elem_mult (beta, beta)); } 
    402424 
    403                 //! Load from structure with elements: 
    404                 //!  \code 
    405                 //! { alpha = [...];         // vector of alpha 
    406                 //!   beta = [...];          // vector of beta 
    407                 //!   rv = {class="RV",...}  // description 
    408                 //! } 
    409                 //! \endcode 
    410                 //!@} 
     425                /*! Create Gamma density  
     426                \f[ f(rv|rvc) = \Gamma(\alpha, \beta) \f] 
     427                from structure 
     428                \code 
     429                class = 'egamma'; 
     430                alpha = [...];         // vector of alpha 
     431                beta = [...];          // vector of beta 
     432                rv = RV({'name'})      // description of RV 
     433                \endcode 
     434                */ 
    411435                void from_setting (const Setting &set) { 
    412436                        epdf::from_setting (set); // reads rv 
     
    511535                vec mean() const {return (high -low) / 2.0;} 
    512536                vec variance() const {return (pow (high, 2) + pow (low, 2) + elem_mult (high, low)) / 3.0;} 
    513                 //! Load from structure with elements: 
    514                 //!  \code 
    515                 //! { high = [...];          // vector of upper bounds 
    516                 //!   low = [...];           // vector of lower bounds 
    517                 //!   rv = {class="RV",...}  // description of RV 
    518                 //! } 
    519                 //! \endcode 
    520                 //!@} 
     537                /*! Create Uniform density  
     538                \f[ f(rv) = U(low,high) \f] 
     539                from structure 
     540                 \code 
     541                 class = 'euni' 
     542                 high = [...];          // vector of upper bounds 
     543                 low = [...];           // vector of lower bounds 
     544                 rv = RV({'name'});     // description of RV 
     545                 \endcode  
     546                 */ 
    521547                void from_setting (const Setting &set) { 
    522548                        epdf::from_setting (set); // reads rv and rvc 
     
    582608                friend std::ostream &operator<< (std::ostream &os,  mlnorm<sq_M, enorm> &ml); 
    583609 
     610                /*! Create Normal density with linear function of mean value  
     611                 \f[ f(rv|rvc) = N(A*rvc+const, R) \f] 
     612                from structure 
     613                \code 
     614                class = 'mlnorm<ldmat>', (OR) 'mlnorm<chmat>', (OR) 'mlnorm<fsqmat>'; 
     615                A     = [];                  // matrix or vector of appropriate dimension 
     616                const = [];                  // vector of constant term 
     617                R     = [];                  // square matrix of appropriate dimension 
     618                \endcode 
     619                */ 
    584620                void from_setting (const Setting &set) { 
    585621                        mpdf::from_setting (set); 
     
    621657 
    622658 
    623                 /*! UI for mgnorm 
    624  
    625                 The mgnorm is constructed from a structure with fields: 
     659                /*! Create Normal density with given function of mean value  
     660                \f[ f(rv|rvc) = N( g(rvc), R) \f] 
     661                from structure 
    626662                \code 
    627                 system = { 
    628                         type = "mgnorm"; 
    629                         // function for mean value evolution 
    630                         g = {type="fnc"; ... } 
    631  
    632                         // variance 
    633                         R = [1, 0, 
    634                                  0, 1]; 
    635                         // --OR -- 
    636                         dR = [1, 1]; 
    637  
    638                         // == OPTIONAL == 
    639  
    640                         // description of y variables 
    641                         y = {type="rv"; names=["y", "u"];}; 
    642                         // description of u variable 
    643                         u = {type="rv"; names=[];} 
    644                 }; 
     663                class = 'mgnorm'; 
     664                g.class =  'fnc';      // function for mean value evolution 
     665                g._fields_of_fnc = ...; 
     666 
     667                R = [1, 0;             // covariance matrix 
     668                        0, 1]; 
     669                        --OR -- 
     670                dR = [1, 1];           // diagonal of cavariance matrix 
     671 
     672                rv = RV({'name'})      // description of RV 
     673                rvc = RV({'name'})     // description of RV in condition 
    645674                \endcode 
    646  
    647                 Result if 
    648675                */ 
    649676 
    650677                void from_setting (const Setting &set) { 
     678                        mpdf::from_setting(set); 
    651679                        shared_ptr<fnc> g = UI::build<fnc> (set, "g", UI::compulsory); 
    652680 
     
    659687 
    660688                        set_parameters (g, R); 
     689                        validate(); 
     690                } 
     691                void validate() { 
     692                        bdm_assert(g->dimension()==this->dimension(),"incompatible function"); 
    661693                } 
    662694}; 
     
    741773 
    742774                void condition (const vec &val) {_beta = k / val;}; 
    743                 //! Load from structure with elements: 
    744                 //!  \code 
    745                 //! { alpha = [...];         // vector of alpha 
    746                 //!   k = 1.1;               // multiplicative constant k 
    747                 //!   rv = {class="RV",...}  // description of RV 
    748                 //!   rvc = {class="RV",...} // description of RV in condition 
    749                 //! } 
    750                 //! \endcode 
    751                 //!@} 
     775                /*! Create Gamma density with conditional mean value  
     776                \f[ f(rv|rvc) = \Gamma(k, k/rvc) \f] 
     777                from structure 
     778                \code 
     779                  class = 'mgamma'; 
     780                  beta = [...];          // vector of initial alpha 
     781                  k = 1.1;               // multiplicative constant k 
     782                  rv = RV({'name'})      // description of RV 
     783                  rvc = RV({'name'})     // description of RV in condition 
     784                 \endcode 
     785                */ 
    752786                void from_setting (const Setting &set) { 
    753787                        mpdf::from_setting (set); // reads rv and rvc 
     
    877911                }; 
    878912 
    879                 /*! UI for migamma_ref 
    880  
    881                 The migamma_ref is constructed from a structure with fields: 
     913 
     914                /*! Create inverse-Gamma density with conditional mean value  
     915                \f[ f(rv|rvc) = i\Gamma(k, k/(rvc^l \circ ref^{(1-l)}) \f] 
     916                from structure 
    882917                \code 
    883                 system = { 
    884                         type = "migamma_ref"; 
    885                         ref = [1e-5; 1e-5; 1e-2 1e-3];            // reference vector 
    886                         l = 0.999;                                // constant l 
    887                         k = 0.1;                                  // constant k 
    888                          
    889                         // == OPTIONAL == 
    890                         // description of y variables 
    891                         y = {type="rv"; names=["y", "u"];}; 
    892                         // description of u variable 
    893                         u = {type="rv"; names=[];} 
    894                 }; 
     918                class = 'migamma_ref'; 
     919                ref = [1e-5; 1e-5; 1e-2 1e-3];            // reference vector 
     920                l = 0.999;                                // constant l 
     921                k = 0.1;                                  // constant k 
     922                rv = RV({'name'})                         // description of RV 
     923                rvc = RV({'name'})                        // description of RV in condition 
    895924                \endcode 
    896  
    897                 Result if 
    898925                 */ 
    899926                void from_setting (const Setting &set); 
     
    914941\f] 
    915942 
     943Function from_setting loads mu and R in the same way as it does for enorm<>! 
    916944*/ 
    917945class elognorm: public enorm<ldmat> 
     
    928956Mean value, \f$\mu\f$, is... 
    929957 
    930 ==== Check == vv = 
    931 Standard deviation of the random walk is proportional to one \f$k\f$-th the mean. 
    932 This is achieved by setting \f$\alpha=k\f$ and \f$\beta=k/\mu\f$. 
    933  
    934 The standard deviation of the walk is then: \f$\mu/\sqrt(k)\f$. 
    935958 */ 
    936959class mlognorm : public mpdf_internal<elognorm> 
     
    961984                }; 
    962985 
    963                 /*! UI for mlognorm 
    964  
    965                 The mlognorm is constructed from a structure with fields: 
     986                /*! Create logNormal random Walk 
     987                \f[ f(rv|rvc) = log\mathcal{N}( \log(rvc)-0.5\log(k^2+1), k I) \f] 
     988                from structure 
    966989                \code 
    967                 system = { 
    968                         type = "mlognorm"; 
    969                         k = 0.1;                                  // constant k 
    970                         mu0 = [1., 1.]; 
    971                          
    972                         // == OPTIONAL == 
    973                         // description of y variables 
    974                         y = {type="rv"; names=["y", "u"];}; 
    975                         // description of u variable 
    976                         u = {type="rv"; names=[];} 
    977                 }; 
     990                class = 'mlognorm'; 
     991                k   = 0.1;               // "variance" k 
     992                mu0 = 0.1;               // Initial value of mean 
     993                rv  = RV({'name'})       // description of RV 
     994                rvc = RV({'name'})       // description of RV in condition 
    978995                \endcode 
    979  
    980                  */ 
     996                */ 
    981997                void from_setting (const Setting &set); 
    982998