MathGroup Archive 2009

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

Search the Archive

Re: Random choice

You need to do sampling without replacement. This code fragment will sample 
m times (without replacement) from a pool of n indices:



The code returns 2 lists: the sampled indices and the residue of the pool 
which was sampled from. This output can be fed back into the code fragment 
for further sampling if required.

Stephen Luttrell
West Malvern, UK

"Valeri Astanoff" <astanoff at> wrote in message 
news:guj8ef$hv6$1 at
> Good day,
> Given this example :
> In[1]:= RandomChoice[Range[500], 100] // Union // Length
> Out[1]= 91
> what is the best way to get *exactly* 100 different
> random numbers ranging from 1 to 500 ?
> Any piece of advice would be appreciated.
> --
> Valeri Astanoff

  • Prev by Date: Exports to eps, pdf ImageSize
  • Next by Date: Re: SparseArray and Compile
  • Previous by thread: Re: Random choice
  • Next by thread: Re: Random choice