Re: Random Sampling Without Replacement?
- To: mathgroup at smc.vnet.net
- Subject: [mg26632] Re: Random Sampling Without Replacement?
- From: "Hermann Meier" <hmeier at webshuttle.ch>
- Date: Sat, 13 Jan 2001 22:36:11 -0500 (EST)
- Organization: EUnet AG, Switzerland. A KPNQwest Company.
- References: <93edpc$cn@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
"A. E. Siegman" <siegman at stanford.edu> wrote in message news:93edpc$cn at smc.vnet.net... > Looking for neat compact way to extract three distinct (i.e., nonequal) > randomly selected integers k1, k2, k3 from the range 1 to N (N > 3) -- > in other words, random sampling without replacement -- ??? According to D. Knuth, The Art of Computer Programming, Vol. 2, 3rd ed., Ch. 3.4.2, exercise 16, and D. Ripley, Stochastic Simulation, p. 80, the following simple code also works: {nn, n} = {52, 3}; result = {}; While[Length[result] < n, result = Union[Append[result, Random[Integer, {1, nn}]]]]; result With best regards Hermann Meier