-
Notifications
You must be signed in to change notification settings - Fork 0
/
gh_transform.m
53 lines (49 loc) · 1.52 KB
/
gh_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
function [mu,S,C,SX,W] = gh_transform(m,P,g,g_param,tr_param)
% GH_TRANSFORM - Gauss-Hermite transform of random variables
%
% Syntax:
% [mu,S,C,SX,W] = GH_TRANSFORM(M,P,g,p,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 the integration method in form {p}:
% p - Number of points in Gauss-Hermite integration
%
%
% Out:
% mu - Estimated mean of y
% S - Estimated covariance of y
% C - Estimated cross-covariance of x and y
% SX - Sigma points of x
% W - Weights as cell array
% Copyright (c), 2009, 2010 Hartikainen, Särkkä, Solin
%
% 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.
%%
if nargin > 4
p = tr_param{1};
else
p = 3;
end
% Estimate the mean of g
if nargin < 4
[mu,SX,x,W,F] = ngausshermi(g,p,m,P);
else
[mu,SX,x,W,F] = ngausshermi(g,p,m,P,g_param);
end
% Estimate the P and C
if nargin < 5
[pc,SX,x,W,FPC] = ngausshermi(@gh_packed_pc,p,m,P,{g,m,mu});
else
[pc,SX,x,W,FPC] = ngausshermi(@gh_packed_pc,p,m,P,{g,m,mu,g_param});
end
d = size(m,1);
s = size(mu,1);
S = reshape(pc(1:s^2),s,s);
C = reshape(pc(s^2+(1:s*d)),d,s);