Lottery
- To: mathgroup at christensen.cybernetics.net
- Subject: [mg409] Lottery
- From: donald darling <ddarling at math.uci.edu>
- Date: Sun, 15 Jan 95 12:55:44 -0800
Yet another simple procedure to select, without replacement, a random
sample S of size k from the first n integers.
(S={};CS=Range[n];For[j=1,j<=k,j++,
AppendTo[S,x={CS[[ Random[Integer,{1,n-j+1}] ]]}];
CS=Complement[CS,x] ];Flatten[S])
Note that if k>n/2 it is quicker to select a sample of size n-k and then
choose CS, the complement of S, from the above.