Simple. Suppose you have 1110 groups of data (let us say vectors).
Firstly you can import all the 1110 groups into your disk and saved them in a matrix, say matrix A.
Now suppose you have 1110 rows for the matrix.
then define a 2*1110 matrix (say matrix B), 1st col for the indexes, from row 1: 1, row2:2, ..., last row: 1110.
then draw 1110*1 vector of uniform(0,1) random numbers. store this vector into the 2nd col of this matrix B.
then sort matrix B on the 2nd col, say from small to large values. then keep/choose the first 500 rows.
note that the index values corresponding the 500 rows are now disordered.
then use such indexes to help keep the vectors(groups of data) for further analysis.
----------------
Note that the above analysis is absed on the requirement that each group has the probability of 500/1110 to be selected.
and also based on the fact that you need 500 and only 500 groups.
----------------
Ensure that you understand what you really want to...
------------------
sortc(.,.) is in ascending order, to use desceding order, use rev(...)
------------------------------
[此贴子已经被作者于2006-2-20 3:44:26编辑过]