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


Groups > comp.soft-sys.math.mathematica > #13197 > unrolled thread

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

Started bybrtubb090530@cox.net
First post2013-01-18 05:50 +0000
Last post2013-01-19 06:14 +0000
Articles 5 — 4 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Needing a Random List of Non-repeating Values whose Range and Length brtubb090530@cox.net - 2013-01-18 05:50 +0000
    Re: Needing a Random List of Non-repeating Values whose Range and Length buxi@gmx.at - 2013-01-19 06:13 +0000
    Re: Needing a Random List of Non-repeating Values whose Range and Length svkeeley@aol.com - 2013-01-19 06:14 +0000
    Re: Needing a Random List of Non-repeating Values whose Range and Length Szabolcs Horvát <szhorvat@gmail.com> - 2013-01-19 06:13 +0000
    Re: Needing a Random List of Non-repeating Values whose Range and Length svkeeley@aol.com - 2013-01-19 06:14 +0000

#13197 — Needing a Random List of Non-repeating Values whose Range and Length

Frombrtubb090530@cox.net
Date2013-01-18 05:50 +0000
SubjectNeeding a Random List of Non-repeating Values whose Range and Length
Message-ID<kdanrk$3ec$1@smc.vnet.net>
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.

[toc] | [next] | [standalone]


#13210

Frombuxi@gmx.at
Date2013-01-19 06:13 +0000
Message-ID<kdddid$a15$1@smc.vnet.net>
In reply to#13197
Hi!

RandomSample would do the job.
(http://reference.wolfram.com/mathematica/ref/RandomSample.html)

Kind regards,
Thomas


Am Freitag, 18. Januar 2013 06:50:44 UTC+1 schrieb BenT:
> 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.

[toc] | [prev] | [next] | [standalone]


#13213

Fromsvkeeley@aol.com
Date2013-01-19 06:14 +0000
Message-ID<kdddk3$a28$1@smc.vnet.net>
In reply to#13197
Try using RandomSample. This chooses items from a list (or range) without replacement.

[toc] | [prev] | [next] | [standalone]


#13214

FromSzabolcs Horvát <szhorvat@gmail.com>
Date2013-01-19 06:13 +0000
Message-ID<kdddiu$a1j$1@smc.vnet.net>
In reply to#13197
On 2013-01-18 05:50:44 +0000, brtubb090530@cox.net said:

> 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.

The subject line is cut off.  Please do not put the question in the 
subject *only*.

>From the body of your message it looks like you want a random 
permutation of Range[range] which can be computed using 
RandomSample@Range[range]

[toc] | [prev] | [next] | [standalone]


#13216

Fromsvkeeley@aol.com
Date2013-01-19 06:14 +0000
Message-ID<kdddje$a1p$1@smc.vnet.net>
In reply to#13197
Try RandomSample[{list},n], which gives n samples from a list or a range without replacement (each element can only be used once).

I've tried to respond to this a couple of times, and my reply never showed up. So if this message shows up duplicated, that's why.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web