Revision 944, 0.7 kB
(checked in by smidl, 15 years ago)
|
Doc + new examples
|
Line | |
---|
1 | classdef mexLaplace < mexEpdf |
---|
2 | properties |
---|
3 | % from wikipedia |
---|
4 | mu |
---|
5 | b |
---|
6 | end |
---|
7 | methods |
---|
8 | function m=mean(obj) |
---|
9 | m = obj.mu; |
---|
10 | end |
---|
11 | function obj=validate(obj) |
---|
12 | if length(obj.mu)~=length(obj.b) |
---|
13 | error('incompatible mu and b'); |
---|
14 | end |
---|
15 | end |
---|
16 | function dim=dimension(obj) |
---|
17 | dim = size(obj.mu,1); |
---|
18 | end |
---|
19 | function v=variance(obj) |
---|
20 | v=2*obj.b^2; |
---|
21 | end |
---|
22 | function l=evallog(obj,x) |
---|
23 | l=-log(2*obj.b)-abs(x-obj.mu)/obj.b; |
---|
24 | end |
---|
25 | function s=sample(obj) |
---|
26 | v=-log(rand);%sample_exponential(0,1); |
---|
27 | z = randn; |
---|
28 | s = obj.mu+obj.b*sqrt(2*v)*z; |
---|
29 | end |
---|
30 | end |
---|
31 | end |
---|