Show
Ignore:
Timestamp:
05/16/10 23:13:21 (14 years ago)
Author:
smidl
Message:

Doc + new examples

Location:
applications/bdmtoolbox
Files:
5 added
1 removed
7 modified

Legend:

Unmodified
Added
Removed
  • applications/bdmtoolbox/mex/RV.m

    r937 r944  
    33 
    44if nargin<1 
    5     names=''; 
     5    names={}; 
    66end 
    77r.class='RV'; 
  • applications/bdmtoolbox/mex/class_defaults.cpp

    r797 r944  
    1717#include <mex/mex_parser.h> 
    1818#include <mex/mex_function.h> 
     19#include <mex/mex_BM.h> 
    1920 
    2021void mexFunction ( int n_output, mxArray *output[], int n_input, const mxArray *input[] ) { 
     
    2526                                                "output:\n" 
    2627                                                "  the same structure filled with the defaults.\n\n" 
    27                                                 "This operation is usefull for obtaining info about a class construction" ); 
     28                                                "This operation is usefull for obtaining info about class defaults, or success of passing info to it" ); 
    2829 
    2930        RV::clear_all(); 
  • applications/bdmtoolbox/mex/estimator.cpp

    r863 r944  
    8989                if ( n_input>3 ) { 
    9090                        Cfg.addGroup ( input[3],"logger" ); 
    91                 }/*else{ 
    92                 // define logger as mexlog 
    93                 Setting &S=Cfg.getRoot(); 
    94                 S.add("logger",Setting::TypeGroup); 
    95                 S["logger"].add("class",Setting::TypeString); 
    96                 S["logger"]["class"]="mexlog"; 
    97                 S["logger"].add("maxlen",Setting::TypeInt); 
    98                 int maxlen; 
    99                 S["experiment"].lookupValue("ndat",maxlen); 
    100                 S["logger"]["maxlen"]=maxlen; 
    101         }*/ 
     91                } 
    10292        } catch ( SettingException e ) { 
    10393                it_error ( "error: "+string ( e.getPath() ) ); 
  • applications/bdmtoolbox/mex/mex_classes/mexBM.m

    r943 r944  
    11classdef mexBM 
    22    properties 
    3       % from wikipedia 
    4       rv 
    5       rvc 
    6       rvy 
     3        % description of internal variables 
     4        rv=RV 
     5        rvc=RV 
     6        rvy=RV 
     7        % log of evidence (marginal likelihood) potentially computed by the 
     8        % bayes rule for one step 
     9        log_evidence 
     10        % posterior density - offspring of mexEpdf! 
     11        apost_pdf 
     12        % 
    713    end 
     14 
    815    methods 
    9         function validate(p) 
    10                     % checks if all paramateres match 
     16        function p=validate(p) 
     17            % checks if all paramateres match 
    1118        end 
    1219        function dims=dimensions(p) 
     
    2128            % return posterior density 
    2229        end 
     30 
     31        %%%%%%%% default functions %%%%%%%%%%%%%% 
     32        function r = get_rv(obj) 
     33            r=obj.rv; 
     34        end 
     35        function r = get_rvc(obj) 
     36            r=obj.rvc; 
     37        end 
     38        function r = get_rvy(obj) 
     39            r=obj.rvy; 
     40        end 
     41        function ev = logevidence(obj) 
     42            ev = obj.log_evidence; 
     43        end 
     44        function post=posterior(obj); 
     45            post = obj.apost_pdf; 
     46        end 
    2347    end 
    2448end 
  • applications/bdmtoolbox/mex/mex_classes/mexEpdf.m

    r943 r944  
    2020        end 
    2121         
    22         %%% default function %%% 
     22        %%% default functions -- no need to redefine %%% 
    2323         
    2424        function l=evallog_nn(p,x) 
  • applications/bdmtoolbox/mex/mex_classes/mexLaplace.m

    r937 r944  
    66    end 
    77    methods 
    8         function m=mean(p) 
    9             m = p.mu; 
     8        function m=mean(obj) 
     9            m = obj.mu; 
    1010        end 
    11         function validate(p) 
    12             if size(p.mu)<1 & (size(p.b)<1) 
     11        function obj=validate(obj) 
     12            if length(obj.mu)~=length(obj.b) 
    1313                error('incompatible mu and b'); 
    1414            end 
    1515        end 
    16         function dim=dimension(p) 
    17             dim = size(p.mu,1); 
     16        function dim=dimension(obj) 
     17            dim = size(obj.mu,1); 
    1818        end 
    19         function v=variance(p) 
    20             v=2*p.b^2; 
     19        function v=variance(obj) 
     20            v=2*obj.b^2; 
    2121        end 
    22         function l=evallog(p,x) 
    23             l=-log(2*p.b)-abs(x-p.mu)/p.b; 
     22        function l=evallog(obj,x) 
     23            l=-log(2*obj.b)-abs(x-obj.mu)/obj.b; 
    2424        end 
    25         function s=sample(p); 
     25        function s=sample(obj) 
    2626            v=-log(rand);%sample_exponential(0,1); 
    2727            z = randn; 
    28             s = p.mu+p.b*sqrt(2*v)*z; 
     28            s = obj.mu+obj.b*sqrt(2*v)*z; 
    2929        end 
    3030    end 
  • applications/bdmtoolbox/tutorial/userguide/pdfds_example.m

    r940 r944  
    11clear all 
    22% name random variables 
    3 y = RV({'y'},1); 
    4 u = RV({'u'},1); 
     3x = RV({'x'},2); 
    54 
    6 % create f(y_t| y_{t-3}, u_{t-1}) 
    7 fy.class = 'mlnorm<ldmat>'; 
    8 fy.rv    = y; 
    9 fy.rvc   = RVtimes([y,u], [-3, -1]); 
    10 fy.A     = [0.5, -0.9]; 
    11 fy.const = 0; 
    12 fy.R     = 1e-2; 
    135 
    14 % create f(u_t| ) 
    15 fu.class = 'enorm<ldmat>'; 
    16 fu.rv    = u; 
    17 fu.mu    = 0; 
    18 fu.R     = 1e-1; 
     6fx.class  = 'mgnorm<ldmat>';              
     7fx.rv     = x;              
     8fx.rvc    = RVtimes(x,-1);              
     9fx.g      = 'mexFunction';              % function is evaluated in matlab 
     10fx.g.function = 'test_function';         % name of the matlab function to evaluate 
     11fx.g.dim  = 2;                          % expected dimension of output 
     12fx.g.dimc = 2;                          % expected dimension of input 
     13fx.R      = eye(2);                     % variance R 
     14 
    1915 
    2016% create DS 
    2117DS.class = 'PdfDS'; 
    2218DS.pdf.class  = 'mprod'; 
    23 DS.pdf.pdfs  = {fy, fu}; 
    24 DS.init_rv = RVtimes([y,y,y], [-1,-2,-3]); 
    25 DS.init_values = [0.1, 0.2, 0.3]; 
     19DS.pdf.pdfs  = {fx, fu}; 
     20DS.init_rv = RVtimes([x], [-1]); 
     21DS.init_values = [0.1, 0.2]; 
    2622 
    2723experiment.ndat=100;