MathGroup Archive 2009

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

Search the Archive

Re: Random choice


Here is one suggestion:

Nest[Append[#, RandomChoice[Complement[Range[500], #]]] &, {}, 100]

First time we execute RandomChoice, a number among 500 is chosen. 
The next time that number is excluded from the list.
Next time two numbers are excluded, and so on.

Best regards

Ingolf Dahl

-----Original Message-----
From: Valeri Astanoff [mailto:astanoff at gmail.com] 
Sent: den 15 maj 2009 10:22
To: mathgroup at smc.vnet.net
Subject: [mg99838] [mg99831] Random choice

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: Re: Random choice
  • Next by Date: Re: saving initialization cells as a .m file
  • Previous by thread: Re: Random choice
  • Next by thread: Re: Random choice