MathGroup Archive 2009

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

Search the Archive

Re: Random choice

  • To: mathgroup at smc.vnet.net
  • Subject: [mg99838] Re: [mg99831] Random choice
  • From: <ingolf.dahl at telia.com>
  • Date: Fri, 15 May 2009 06:26:15 -0400 (EDT)
  • Organization: University of Gothenburg
  • References: <200905150822.EAA18773@smc.vnet.net>
  • Reply-to: <ingolf.dahl at physics.gu.se>

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



  • References:
  • 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