[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Shuffling elements in a dataset
From: |
jcardoso |
Subject: |
Shuffling elements in a dataset |
Date: |
Fri, 21 Feb 97 22:02:24 GMT |
Hi,
I have the need to randomize the order (shuffle) of very large
datasets. The way I devise, randonly sampling with elimination, is
not very efficient. Is there a better way, using octave's matrix
manipulation?
My way:
nm = num = rows(data);
for i=1:num
rn = ceil(rand * nm--);
new_data(i,:) = data(rn,:);
data(rn,:) = [];
endfor
Better way: perhaps creating a vector of unique indexes? but how to
do this?
idx = 1:rows(data);
now shuffle idx
new_data = data(idx,:)
Of course, this it is the same problem in one dimension...
Thanks,
Joao
--
Joao Cardoso, INESC | e-mail: address@hidden
R. Jose Falcao 110 | tel: + 351 2 2094345
4050 Porto, Portugal | fax: + 351 2 2008487
- Shuffling elements in a dataset,
jcardoso <=