Revision 983, 1.4 kB
(checked in by smidl, 14 years ago)
|
doc - extensions
|
Rev | Line | |
---|
[944] | 1 | classdef mexDirac < mexEpdf |
---|
| 2 | % Dirac delta probability distribution |
---|
[983] | 3 | properties % DATA structures |
---|
| 4 | point % point of the support |
---|
[944] | 5 | end |
---|
| 6 | methods |
---|
[983] | 7 | function m=mean(obj) % compute mean values of the density |
---|
[944] | 8 | m = obj.point; |
---|
| 9 | end |
---|
[983] | 10 | function obj=validate(obj) % check if data structures are consistent |
---|
[944] | 11 | % point should be a column |
---|
| 12 | if (size(obj.point,2)>1) |
---|
| 13 | if (size(obj.point,1)==1) % it is row |
---|
| 14 | obj.point = obj.point'; |
---|
| 15 | end |
---|
| 16 | else |
---|
| 17 | error('Point in mexDirac is not a vector'); |
---|
| 18 | end |
---|
| 19 | end |
---|
[983] | 20 | function dim=dimension(obj) % inform others about your dimensions |
---|
[944] | 21 | dim = size(obj.point,1); |
---|
| 22 | end |
---|
[983] | 23 | function v=variance(obj) % compute variance |
---|
[944] | 24 | v=zeros(size(obj.point)); |
---|
| 25 | end |
---|
[983] | 26 | function l=evallog(obj,x) % return logarithm of your density at point x |
---|
[944] | 27 | if obj.point==x |
---|
| 28 | l = inf; |
---|
| 29 | else |
---|
| 30 | l=0; |
---|
| 31 | end |
---|
| 32 | end |
---|
[983] | 33 | function s=sample(obj); % return random sample from your density |
---|
[944] | 34 | s = obj.point; |
---|
| 35 | end |
---|
| 36 | end |
---|
| 37 | end |
---|