root/applications/bdmtoolbox/mex/mex_classes/mexGauss.m @ 1191

Revision 1191, 1.1 kB (checked in by smidl, 14 years ago)

OO implementation of Kalman in Matlab

Line 
1%> @file mexLaplace.m
2%> @brief Matlab implementation of Gaussian density
3% ======================================================================
4%> @brief Unconditional Gaussian density
5%
6%> \f[ f(x|\mu,b) \propto \exp(-(x-\mu)'R^{-1}(x-\mu))\f]
7% ======================================================================
8classdef mexGauss < mexEpdf
9    properties
10        mu % mean values
11        R  % variance
12    end
13    methods
14        function m=mean(obj)
15            m = obj.mu;
16        end
17        function obj=validate(obj)
18            if size(obj.R,1)~=size(obj.R,2)
19                error('matrix R is not square');
20            end
21            if length(obj.mu)~=size(obj.R,1)
22                error('incompatible mu and R');
23            end
24        end
25        function dim=dimension(obj)
26            dim = size(obj.mu,1);
27        end
28        function v=variance(obj)
29            v=diag(R);
30        end
31        function l=evallog(obj,x)
32            l=-log(2*obj.b)-abs(x-obj.mu)/obj.b;
33        end
34        function s=sample(obj)
35            z = randn(obj.dimension);
36            s = obj.mu+chol(R)'*z;
37        end
38    end
39end
Note: See TracBrowser for help on using the browser.