Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #13202

Re: Needing a Random List of Non-repeating Values whose Range and Length

From Bill Rowe <readnews@sbcglobal.net>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Needing a Random List of Non-repeating Values whose Range and Length
Date 2013-01-19 06:13 +0000
Message-ID <kdddj3$a1l$1@smc.vnet.net> (permalink)
Organization Time-Warner Telecom

Show all headers | View raw


On 1/18/13 at 12:54 AM, brtubb090530@cox.net wrote:

>Consider the following:

>ril[range_Integer]:= RandomInteger[{1,range},range]

>This function is almost what I want; but I need one which doesn't
>include any repeated values. This is intended for use, for example,
>for a card deck, or dice, etc.

Perhaps you should look at RandomSample. For example, if you
associate the integers from 1 to 52 with the 52 possible cards
(excluding jokers) in a deck

RandomSample[Range@52,5]

would return 5 values representing a random 5 card draw from the deck

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: Needing a Random List of Non-repeating Values whose Range and Length Bill Rowe <readnews@sbcglobal.net> - 2013-01-19 06:13 +0000

csiph-web