A pseudocode for the data split implementation:
inds= 1...n; // divide randomly to N slots
for k=1...N
n(k)= round(n/(N-k+1)); // size of this chunk
n= n-n(k); // number of samples left to divide later…
slotInds(k)= chooseNfromSet(inds, n(k)); // chooses n(k) samples from inds!
inds= setdifference(inds, slotInds(k)); // samples left to divide later…
end
assert: sum(k=1...5, n(k)) == N // this should hold true now!
chooseNfromSet(inds,n) ==
randsample(inds,n) % in matlab
#
My response to the pseudocode above in Matlab is:
inds=1:n;
for k=1:N
n(k)= round(n/(N-k+1));
n= n-n(k);
slotInds(k)= randsample(inds,n);
inds= setdifference(inds, slotInds(k));
end
#
However there is error
In an assignment A(:) = B, the number of elements in A and B must be the same.
and i cant understand the last line of pseudocode
assert: sum(k=1...5, n(k)) == N