Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2001
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2001

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Random Sampling Without Replacement

  • To: mathgroup at smc.vnet.net
  • Subject: [mg26594] Re: Random Sampling Without Replacement
  • From: "Ersek, Ted R" <ErsekTR at navair.navy.mil>
  • Date: Thu, 11 Jan 2001 10:39:08 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

A. E. Seigman wanted a neat compact way to randomly selected three integers
from 1 to N (N>3).  Everything needed is in a standard package.


In[1]:=
  <<DiscreteMath`Combinatorica`

For three random numbers between 1 and 50 use:

In[2]:=
  Part[ RandomKSubset[Range[50], 3],  RandomPermutation[3] ]

Out[2]=
  {14, 12, 38}

You can also use RandomPermutation1 or RandomPermutation2 instead of
RandomPermutation which are in the same package.  However, I haven't figured
out the difference between the three types.  You can also check the
implementation of the package to possibly get ideas on how to make it work
faster.

--------------------
Regards,
Ted Ersek

Download Mathematica tips, tricks from 
http://www.verbeia.com/mathematica/tips/Tricks.html



  • Prev by Date: Re: Random Sampling Without Replacement?
  • Next by Date: Re: Random Sampling Without Replacement?
  • Previous by thread: Re: Plotting complex points
  • Next by thread: Re: Expansion Coefficients in Multivariable Series Expansions?