-
Notifications
You must be signed in to change notification settings - Fork 40
/
lin_transform.m
82 lines (69 loc) · 1.76 KB
/
lin_transform.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
%UT_TRANSFORM Perform linearization based transform of a Gaussian rv
%
%
% Syntax:
% [mu,S,C,X,Y,w] = LIN_TRANSFORM(M,P,g,g_param,tr_param)
%
% In:
% M - Random variable mean (Nx1 column vector)
% P - Random variable covariance (NxN pos.def. matrix)
% g - Transformation function of the form g(x,param) as
% matrix, inline function, function name or function reference
% g_param - Parameters of g (optional, default empty)
% tr_param - Parameters of linearization as a cell array with elements:
% tr_param{1} = derivative function gx of g
%
% Out:
% mu - Estimated mean of y
% S - Estimated covariance of y
% C - Estimated cross-covariance of x and y
%
% Description:
% ...
% For default values of parameters, see UT_WEIGHTS.
%
% See also
% UT_WEIGHTS UT_MWEIGHTS UT_SIGMAS
% Copyright (C) 2006 Simo S�rkk�
%
% $Id: ut_transform.m 111 2007-09-04 12:09:23Z ssarkka $
%
% This software is distributed under the GNU General Public
% Licence (version 2 or later); please refer to the file
% Licence.txt, included with the software, for details.
function [mu,S,C] = lin_transform(M,P,g,g_param,tr_param)
if nargin < 4
g_param = [];
end
if nargin < 5
tr_param = [];
end
%
% Apply defaults
%
if isempty(tr_param)
gx = [];
else
gx = tr_param{1};
end
if isempty(gx)
gx = eye(size(M,1));
end
if isnumeric(gx)
% nop
elseif isstr(gx) | strcmp(class(gx),'function_handle')
gx = feval(gx,M,g_param);
else
gx = gx(M,g_param);
end
if isempty(g)
mu = g*M;
elseif isnumeric(g)
mu = g;
elseif isstr(g) | strcmp(class(g),'function_handle')
mu = feval(g,M,g_param);
else
mu = g(M,g_param);
end
S = gx*P*gx';
C = P*gx';