Changeset 1083

Show
Ignore:
Timestamp:
06/11/10 14:18:09 (14 years ago)
Author:
smidl
Message:

Mergers + fixes

Files:
8 modified

Legend:

Unmodified
Added
Removed
  • applications/bdmtoolbox/doc/from_bdm/make_all.sh

    r1054 r1083  
    77./process_class.sh bdm::logger 
    88./process_class.sh bdm::Controller 
     9./process_class.sh bdm::MergerBase 
    910 
    1011cp -u ../../../../library/doc/html/*.png ../html/bdm_doc 
  • applications/bdmtoolbox/mex/epdf_1dplot.m

    r803 r1083  
    1 function epdf_1dplot(pdf,xlims, points) 
     1function h=epdf_1dplot(pdf,xlims, points) 
    22% function evaluates given pdf on support 
    33%  xlims = [x_begin, x_end] --or-- empty 
     
    1717x = xlims(1):steps/(points-1):xlims(2); 
    1818v = epdf_evallog_mat(pdf,x); 
    19 plot(x,exp(v)); 
     19h=plot(x,exp(v)); 
  • applications/bdmtoolbox/mex/epdf_evallog_mat.cpp

    r943 r1083  
    1818        if ( n_input<1 ) mexErrMsgTxt ( "Usage:\n" 
    1919                                                "mat=pdf_evallog_mat(pdf_struct, nos)\n" 
    20                                                 "  pdf_struct = struct('class','pdf_offspring',...);  % description of pdf\n" 
    21                                                 "  points     = pdf_dimension x npoints matrix;                           % points in which to evaluate\n" 
     20                                                "  pdf_struct = struct('class','pdf_offspring',...);      % description of pdf\n" 
     21                                                "  points     = pdf_dimension x npoints matrix;           % points in which to evaluate\n" 
    2222                                                "output:\n" 
    2323                                                "  vector of log-likelihoods" ); 
  • applications/bdmtoolbox/mex/merger.cpp

    r1079 r1083  
    11#include <stat/merger.h> 
     2 
     3using namespace bdm; 
    24 
    35#ifdef MEX 
    46#include <itpp/itmex.h> 
    57#include <mex/mex_logger.h> 
    6 #include <mex/mex_parser.h> 
     8#include <mex/mex_merger.h> 
    79#endif 
    810 
     
    1416\code 
    1517Sources = (... any epdf or mpdf  ...); 
    16 Support = {grid=([low1d,high1d],[low2d,high2d],...); 
    17                    nbins=[bins1d,bins2d,... ]}; 
     18Support = rectangular_support or discrete_support; 
    1819// OR 
    1920Support = {pdf={class='epdf',...}; 
     
    3233        if ( n_input != 3 ) mexErrMsgTxt ( "Usage:\n" 
    3334                                                   "result=merger(sources, support, merger)\n" 
    34                                                    "  sources= { struct('class','epdf'),... };  % cell of pdfs (epdfs or mpdfs) to be merged,\n" 
    35                                                    "  support= struct(\n" 
    36                                                    "           grid    = {[dim1_start,dim1_end], [dim2_start, dim2_end]...}  %support boundary \n" 
    37                                                    "           nbins   = [bins_in_dim1, bins_in_dim2,...]                    %fixed \n" 
    38                                                    "         === OR ==\n" 
    39                                                    "           pdf     = struct('class','epdf'); % pdf to draw samples from\n" 
    40                                                    "           nsamples= 100;                    % number of samples\n" 
    41                                                    "           );\n" 
    42                                                    "        If all elements are present,  (grid,nbins) is used;\n" 
    43                                                    "  merger = struct('class','merger_*');       % object to be used for merging,\n\n" 
    44                                                    "see documentation of classes epdf, mpdf, merger_base and their offsprings in BDM." ); 
     35                                                   "  sources= { bdm::epdf,... };               % cell of pdfs (epdfs or mpdfs) to be merged,\n" 
     36                                                   "  support= bdm::rectangular_support;        % points onwhich to merge       \n" 
     37                                                                                   "    - or - bdm::discrete_support\n" 
     38                                                   "  merger = bdm::MergerDiscrete;             % object to be used for merging,\n\n" ); 
    4539        RV::clear_all(); 
    4640        // LOAD CONFIG 
  • library/bdm/mex/mex_pdf.h

    r1064 r1083  
     1using namespace bdm; 
     2 
    13class mexEpdf: public epdf { 
    24protected: 
  • library/bdm/stat/exp_family.cpp

    r1079 r1083  
    415415 
    416416 
    417 double egamma::evallog ( const vec &val ) const { 
     417double egamma::evallog_nn ( const vec &val ) const { 
    418418    double res = 0.0; //the rest will be added 
    419419    int i; 
     
    424424        res += ( alpha ( i ) - 1 ) * std::log ( val ( i ) ) - beta ( i ) * val ( i ); 
    425425    } 
    426     double tmp = res - lognc();; 
    427     bdm_assert_debug ( std::isfinite ( tmp ), "Infinite value" ); 
    428     return tmp; 
     426    return res; 
    429427} 
    430428 
  • library/bdm/stat/exp_family.h

    r1079 r1083  
    893893 
    894894    vec sample() const; 
    895     double evallog ( const vec &val ) const; 
    896     double lognc () const; 
     895        double evallog_nn ( const vec &val ) const; 
     896        double lognc () const; 
    897897    //! Returns pointer to internal alpha. Potentially dengerous: use with care! 
    898898    vec& _alpha() { 
  • library/bdm/stat/merger.h

    r1079 r1083  
    3838                //!  
    3939                //! check if all epdfs are on the same support 
    40                 void validate_sources() { 
    41                         int n=sources.length(); 
     40                virtual void set_sources(const Array<shared_ptr<pdf> > &A) { 
     41                        int n=A.length(); 
    4242                         
    4343                        bdm_assert(n>0,"merger has no sources to merge"); 
     
    4848                         
    4949                        // check compatibility of sources -- no types are needed 
    50                         int dim0 = sources(0)->dimension(); 
     50                        int dim0 = A(0)->dimension(); 
    5151                        for (int i=0; i<n; i++){ 
     52                                const epdf *si=dynamic_cast<const epdf*>(A(i).get()); 
     53                                if (si){ 
     54                                        sources(i) = dynamic_cast<epdf*>(A(i)->_copy()); 
     55                                } 
    5256                                bdm_assert(sources(i)->dimension()==dim0, "Merger: Incompatible dimensions of sources"); 
    5357                                if (sources(i)->isnamed()){