-
Notifications
You must be signed in to change notification settings - Fork 40
/
ut_mweights.m
50 lines (45 loc) · 1.18 KB
/
ut_mweights.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
%UT_MWEIGHTS - Generate matrix form unscented transformation weights
%
% Syntax:
% [WM,W,c] = ut_mweights(n,alpha,beta,kappa)
%
% In:
% n - Dimensionality of random variable
% alpha - Transformation parameter (optional, default 0.5)
% beta - Transformation parameter (optional, default 2)
% kappa - Transformation parameter (optional, default 3-size(X,1))
%
% Out:
% WM - Weight vector for mean calculation
% W - Weight matrix for covariance calculation
% c - Scaling constant
%
% Description:
% Computes matrix form unscented transformation weights.
%
% Copyright (C) 2006 Simo Särkkä
%
% $Id$
%
% 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 [WM,W,c] = ut_mweights(n,alpha,beta,kappa)
%
% Check which arguments are there
%
if nargin < 1
error('At least dimensionality n required.');
end
if nargin < 2
alpha = [];
end
if nargin < 3
beta = [];
end
if nargin < 4
kappa = [];
end
[WM,WC,c] = ut_weights(n,alpha,beta,kappa);
W = eye(length(WC)) - repmat(WM,1,length(WM));
W = W * diag(WC) * W';