Show
Ignore:
Timestamp:
05/25/10 20:55:06 (14 years ago)
Author:
smidl
Message:

estimator returns the array of posterior estimators as second argument

Location:
applications/bdmtoolbox
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • applications/bdmtoolbox/mex/estimator.cpp

    r966 r979  
    3838Execute command: 
    3939\code 
    40 >> estimator('config_file.cfg'); 
     40>> estimator 
    4141\endcode 
    42 when using loggers storing results on hard drives, and 
    43 \code 
    44 >> Res=estimator('config_file.cfg'); 
    45 \endcode 
    46 when using logger of the type \c "mex_logger". The results will be stored in structure \c M. 
     42and follow the help there. 
    4743 
    4844 */ 
     
    6965        // Check the number of inputs and output arguments 
    7066        if ( n_input<2 ) mexErrMsgTxt ( "Usage:\n" 
    71                                                 "result=estimator(system, estimators, experiment, logger)\n" 
     67                                                "[Res,estimators,Res2]=estimator(system, estimators, experiment, logger)\n" 
    7268                                                "  system     = struct('class','datasource',...);  % Estimated system\n" 
    7369                                                "  estimators = {struct('class','estimator',...),  % Estimators\n" 
     
    7672                                                "  experiment = struct('ndat',10);                 % number of data in experiment, full length of finite datasources, 10 otherwise \n" 
    7773                                                "  logger     = struct('class','mexlogger');       % How to store results, default=mexlog, i.e. matlab structure\n\n" 
     74                                                "Output:\n" 
     75                                                "  Res          Matlab structure with logged results, \n"   
     76                                                "  estimators   Array of estimators updated with data \n" 
     77                                                "  Res2         When logfull log_level is on, this structure is filled with structures of posterior densities\n\n" 
    7878                                                "see documentation of classes datasource, BM, and mexlogger and their offsprings in BDM." ); 
    7979 
     
    206206                if ( n_output<1 ) mexErrMsgTxt ( "Wrong number of output variables!" ); 
    207207                output[0] = mL->toCell(); 
    208                 if (n_output>1) { 
     208                if (n_output>1){ // write estimators 
     209                        UImxArray Ests; 
     210                        UI::save(Es, Ests,"estimators"); 
     211                        output[1]=UImxArray::create_mxArray(Ests); 
     212                } 
     213                if (n_output>2) { 
    209214                        mL->_setting_conf().setAutoConvert(true); 
    210                         output[1]= UImxArray::create_mxArray(mL->_setting_conf().getRoot()); 
     215                        output[2]= UImxArray::create_mxArray(mL->_setting_conf().getRoot()); 
    211216                } 
    212217        } 
    213218#endif 
    214219        for (int i=0;i<Dls.length(); i++){delete Dls(i); delete Dlsc(i);} 
     220        UIFile F; 
     221        UI::save(Es, F.getRoot(),"estimators"); 
     222        F.writeFile("estim_out.cfg"); 
    215223} 
  • applications/bdmtoolbox/tutorial/userguide/arx_basic_example.m

    r968 r979  
    1515A1.log_level = 'logbounds,logevidence'; 
    1616 
    17 M=estimator(DS,{A1}); 
     17[M,Apost]=estimator(DS,{A1}); 
    1818 
    1919%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%