1 function x = random(OBJ, t, varargin)
2 % RANDOM Generate IID samples from Gaussian distribution
3 % R=RANDOM(W, T, M, N, ...) or R=RANDOM(W, T, [M, N, ...]) returns a
4 % MxNx... matrix with IID samples. (T is ignored.)
6 % Copyright (C) 2005 Gustaf Hendeby, Jakob Rosén
8 % This program is free software; you can redistribute it and/or
9 % modify it under the terms of the GNU General Public License
10 % as published by the Free Software Foundation; either version 2
11 % of the License, or (at your option) any later version.
13 % This program is distributed in the hope that it will be useful,
14 % but WITHOUT ANY WARRANTY; without even the implied warranty of
15 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 % GNU General Public License for more details.
18 % You should have received a copy of the GNU General Public License
19 % along with this program; if not, write to the Free Software
20 % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 % Syntax should be identical with standard RANDOM from Stat Toolbox.
24 % FIXME: Improve input check
25 error(nargchk(3, inf, nargin));
26 N = cell2mat(varargin);
29 x = OBJ.mu + sqrt(OBJ.R) * randn(N);
31 % FIXME: Consider the treatment of this case.
33 error('Cannot produce random number arrays for N-dim Gaussians.');
36 x = OBJ.Rsqrtm*randn([OBJ.n, N(2)]);
37 for i = 1:OBJ.n % Probably faster than a repmat
38 x(i, :) = x(i, :) + OBJ.mu(i);