annotate toolboxes/FullBNT-1.0.7/KPMtools/rand_psd.m @ 0:cc4b1211e677 tip

initial commit to HG from Changeset: 646 (e263d8a21543) added further path and more save "camirversion.m"
author Daniel Wolff
date Fri, 19 Aug 2016 13:07:06 +0200
parents
children
rev   line source
Daniel@0 1 function M = rand_psd(d, d2, k)
Daniel@0 2 % Create a random positive definite matrix of size d by d by k (k defaults to 1)
Daniel@0 3 % M = rand_psd(d, d2, k) default: d2 = d, k = 1
Daniel@0 4
Daniel@0 5 if nargin<2, d2 = d; end
Daniel@0 6 if nargin<3, k = 1; end
Daniel@0 7 if d2 ~= d, error('must be square'); end
Daniel@0 8
Daniel@0 9 M = zeros(d,d,k);
Daniel@0 10 for i=1:k
Daniel@0 11 A = rand(d);
Daniel@0 12 M(:,:,i) = A*A';
Daniel@0 13 end