Mercurial > hg > camir-aes2014
comparison toolboxes/FullBNT-1.0.7/KPMtools/partitionData.m @ 0:e9a9cd732c1e tip
first hg version after svn
author | wolffd |
---|---|
date | Tue, 10 Feb 2015 15:05:51 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e9a9cd732c1e |
---|---|
1 function varargout = partitionData(Ndata, varargin) | |
2 % PARTITIONDATA Partition a vector of indices into random sets | |
3 % [a,b,c,...] = partitionData(N, 0.3, 0.2, 0.5, ...) | |
4 % | |
5 % Examples: | |
6 % [a,b,c]=partitionData(105,0.3,0.2,0.5); | |
7 % a= 1:30, b=32:52, c=52:105 (last bin gets all the left over) | |
8 | |
9 Npartitions = length(varargin); | |
10 perm = randperm(Ndata); | |
11 %perm = 1:Ndata; | |
12 ndx = 1; | |
13 for i=1:Npartitions | |
14 pc(i) = varargin{i}; | |
15 Nbin(i) = fix(Ndata*pc(i)); | |
16 low(i) = ndx; | |
17 if i==Npartitions | |
18 high(i) = Ndata; | |
19 else | |
20 high(i) = low(i)+Nbin(i)-1; | |
21 end | |
22 varargout{i} = perm(low(i):high(i)); | |
23 ndx = ndx+Nbin(i); | |
24 end | |
25 |