root/applications/bdmtoolbox/mex/mex_classes/mexDirac.m @ 1455

Revision 1054, 1.7 kB (checked in by smidl, 14 years ago)

doc

Line 
1%> @file mexDirec.m
2%> @brief Matlab implementation of Dirac density
3% ======================================================================
4%> @brief Unconditional Dirac density
5%
6%> \f[ f(x| x_i) = \delta(x-x_i)\f]
7% ======================================================================
8classdef mexDirac < mexEpdf
9    % Dirac delta probability distribution
10    properties                                                 % DATA structures
11        point                                                  % point of the support
12    end
13    methods
14        function m=mean(obj)                                   % compute mean values of the density
15            m = obj.point;
16        end
17        function obj=validate(obj)                             % check if data structures are consistent
18            % point should be a column
19            if (size(obj.point,2)>1)
20                if (size(obj.point,1)==1) % it is row
21                    obj.point = obj.point';
22                end
23            else
24                error('Point in mexDirac is not a vector');
25            end
26        end
27        function dim=dimension(obj)                            % inform others about your dimensions
28            dim = size(obj.point,1);
29        end
30        function v=variance(obj)                               % compute variance
31            v=zeros(size(obj.point));
32        end
33        function l=evallog(obj,x)                              % return logarithm of your density at point x
34            if obj.point==x
35                l = inf;
36            else
37                l=0;
38            end
39        end
40        function s=sample(obj);                                % return random sample from your density
41            s = obj.point;
42        end
43    end
44end
Note: See TracBrowser for help on using the browser.