forked from fietew/ekfukf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgauss_rnd.m
39 lines (33 loc) · 857 Bytes
/
gauss_rnd.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
%GAUSS_RND Multivariate Gaussian random variables
%
% Syntax:
% X = GAUSS_RND(M,S,N)
%
% In:
% M - Dx1 mean of distibution or K values as DxK matrix.
% S - DxD covariance matrix
% N - Number of samples (optional, default 1)
%
% Out:
% X - Dx(K*N) matrix of samples.
%
% Description:
% Draw N samples from multivariate Gaussian distribution
%
% X ~ N(M,S)
%
% See also:
% GAUSS_PDF
% Copyright (C) 2002-2006 Simo Särkkä
%
% $Id: gauss_rnd.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 X = gauss_rnd(M,S,N)
if nargin < 3
N = 1;
end
L = chol(S)';
X = repmat(M,1,N) + L*randn(size(M,1),size(M,2)*N);