Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #13197 > unrolled thread
| Started by | brtubb090530@cox.net |
|---|---|
| First post | 2013-01-18 05:50 +0000 |
| Last post | 2013-01-19 06:14 +0000 |
| Articles | 5 — 4 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
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
| From | brtubb090530@cox.net |
|---|---|
| Date | 2013-01-18 05:50 +0000 |
| Subject | Needing 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]
| From | buxi@gmx.at |
|---|---|
| Date | 2013-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]
| From | svkeeley@aol.com |
|---|---|
| Date | 2013-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]
| From | Szabolcs Horvát <szhorvat@gmail.com> |
|---|---|
| Date | 2013-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]
| From | svkeeley@aol.com |
|---|---|
| Date | 2013-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