forked from milleratotago/Cupid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ExponenMn.m
54 lines (44 loc) · 1.62 KB
/
ExponenMn.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
classdef ExponenMn < Exponential
% ExponenMn distribution: exponential with parameter = mean, not rate.
properties(SetAccess = protected)
expmean
end
methods
function obj=ExponenMn(varargin)
obj=obj@Exponential;
obj.FamilyName = 'ExponenMn';
obj.ParmNames{1} = 'expmean';
if nargin==1
ResetParms(obj,varargin{1});
elseif nargin>1
ME = MException('Exponential:Constructor', ...
'Too many arguments passed to Exponential constructor.');
throw(ME);
end
end
function []=ResetParms(obj,newparmvalues)
ClearBeforeResetParmsC(obj);
obj.expmean = newparmvalues(1);
obj.rate = 1/obj.expmean;
assert(obj.expmean>0,'ExponenMn mean must be > 0.');
ReInit(obj);
end
function PerturbParms(obj,ParmCodes)
% Perturb parameter values prior to estimation attempts.
newmean = ifelse(ParmCodes(1)=='f', obj.expmean, 0.9*obj.expmean);
obj.ResetParms(newmean);
end
% function parmvals = ParmValues(obj,varargin)
% parmvals = obj.expmean;
% end
function s=EstML(obj,Observations,varargin)
if ~obj.Initialized
error(UninitializedError(obj));
end
meanObs = mean(Observations);
ResetParms(obj,meanObs);
BuildMyName(obj);
s=obj.StringName;
end
end
end