-
Notifications
You must be signed in to change notification settings - Fork 1
/
normal_time.m
137 lines (134 loc) · 5.81 KB
/
normal_time.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% AUXILIARY FUNCTIONS FOR NOISE MODELS %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function J_T = normal_time(T,Tm,R,Sigma,ind,nderiv)
T = T(ind);
Tm = Tm(ind);
R = R(ind);
Sigma = Sigma(ind);
if nderiv >= 0
% J_T
J_T.val = sum(0.5*((T - Tm)./Sigma).^2 + 0.5*((R)./Sigma).^2 + log(2*pi*Sigma.^2));
if nderiv >= 1
% dJ_TdT
J_T.dT = transpose((T - Tm)./(Sigma.^2));
% dJ_TdR
J_T.dR = transpose(R./(Sigma.^2));
% dJ_TdSigma
J_T.dSigma = transpose(- (((T - Tm).^2)./(Sigma.^3)) - (((R).^2)./(Sigma.^3)) + 2./Sigma);
if nderiv >= 2
%ddJ_TdTdT
J_T.dTdT = diag(1./(Sigma.^2));
%ddJ_TdTdR
J_T.dTdR = diag(zeros(size(T)));
%ddJ_TdRdR
J_T.dRdR = diag(1./(Sigma.^2));
%ddJ_TdTdSigma
J_T.dTdSigma = diag(-2*(T - Tm)./(Sigma.^3));
%ddJ_TdRdSigma
J_T.dRdSigma = diag(-2*(R)./(Sigma.^3));
%ddJ_TdSigmadSigma
J_T.dSigmadSigma = diag(3*(((T - Tm).^2)./(Sigma.^4)) + 3*(((R).^2)./(Sigma.^4)) - 2./(Sigma.^2));
if nderiv >= 3
%dddJ_TdTdTdT
J_T.dTdTdT = transpose(zeros(size(T)));
%dddJ_TdTdTdR
J_T.dTdTdR = transpose(zeros(size(T)));
%dddJ_TdTdRdR
J_T.dTdRdR = transpose(zeros(size(T)));
%dddJ_TdRdRdR
J_T.dRdRdR = transpose(zeros(size(T)));
%dddJ_TdTdTdSigma
J_T.dTdTdSigma = transpose(- 2./(Sigma.^3));
%dddJ_TdTdRdSigma
J_T.dTdRdSigma = transpose(zeros(size(T)));
%dddJ_TdRdRdSigma
J_T.dRdRdSigma = transpose(- 2./(Sigma.^3));
%dddJ_TdTdSigmadSigma
J_T.dTdSigmadSigma = transpose(6*(T - Tm)./(Sigma.^4));
%dddJ_TdRdSigmadSigma
J_T.dRdSigmadSigma = transpose(6*(R)./(Sigma.^4));
%dddJ_TdSigmadSigmadSigma
J_T.dSigmadSigmadSigma = transpose(- 12*(((T - Tm).^2)./(Sigma.^5)) - 12*(((R).^2)./(Sigma.^5)) + 4./(Sigma.^3));
% if nargout >= 20
% %ddddJ_TdTdTdTdT
% varargout{21} = transpose(zeros(size(T)));
% if(isempty(varargout{21}))
% varargout{21} = zeros(1,0);
% end
% %ddddJ_TdTdTdTdR
% varargout{22} = transpose(zeros(size(T)));
% if(isempty(varargout{22}))
% varargout{22} = zeros(1,0);
% end
% %ddddJ_TdTdTdRdR
% varargout{23} = transpose(zeros(size(T)));
% if(isempty(varargout{23}))
% varargout{23} = zeros(1,0);
% end
% %ddddJ_TdTdRdRdR
% varargout{24} = transpose(zeros(size(T)));
% if(isempty(varargout{24}))
% varargout{24} = zeros(1,0);
% end
% %ddddJ_TdRdRdRdR
% varargout{25} = transpose(zeros(size(T)));
% if(isempty(varargout{25}))
% varargout{25} = zeros(1,0);
% end
% %ddddJ_TdTdTdTdSigma
% varargout{26} = transpose(zeros(size(T)));
% if(isempty(varargout{26}))
% varargout{26} = zeros(1,0);
% end
% %ddddJ_TdTdTdRdSigma
% varargout{27} = transpose(zeros(size(T)));
% if(isempty(varargout{27}))
% varargout{27} = zeros(1,0);
% end
% %ddddJ_TdTdRdRdSigma
% varargout{28} = transpose(zeros(size(T)));
% if(isempty(varargout{28}))
% varargout{28} = zeros(1,0);
% end
% %ddddJ_TdRdRdRdSigma
% varargout{29} = transpose(zeros(size(T)));
% if(isempty(varargout{29}))
% varargout{29} = zeros(1,0);
% end
% %ddddJ_TdTdTdSigmadSigma
% varargout{30} = transpose(6./(Sigma.^4));
% if(isempty(varargout{30}))
% varargout{30} = zeros(1,0);
% end
% %ddddJ_TdTdRdSigmadSigma
% varargout{31} = transpose(zeros(size(T)));
% if(isempty(varargout{31}))
% varargout{31} = zeros(1,0);
% end
% %ddddJ_TdRdRdSigmadSigma
% varargout{32} = transpose(6./(Sigma.^4));
% if(isempty(varargout{32}))
% varargout{32} = zeros(1,0);
% end
% %ddddJ_TdTdSigmadSigmadSigma
% varargout{33} = transpose(- 24*((T - Tm)./(Sigma.^5)));
% if(isempty(varargout{33}))
% varargout{33} = zeros(1,0);
% end
% %ddddJ_TdRdSigmadSigmadSigma
% varargout{34} = transpose(- 24*((R)./(Sigma.^5)));
% if(isempty(varargout{34}))
% varargout{34} = zeros(1,0);
% end
% %ddddJ_TdSigmadSigmadSigmadSigma
% varargout{35} = transpose(60*(((T - Tm).^2)./(Sigma.^6)) + 60*(((R).^2)./(Sigma.^6)) - 12./(Sigma.^4));
% if(isempty(varargout{35}))
% varargout{35} = zeros(1,0);
% end
% end
end
end
end
end
end