Random sequence generator with some specifications
February 9, 2014 12:53 PM
Let's say I have things 1, 2, 3 and 4. I want a sequence of 20 numbers which are either 1, 2, 3 or 4. I want to use all of these numbers an equal number of times, and once that number has exhausted its chances I want it to stop being used in the sequence. Is there a free program, or an easy way to do this in Excel / Google Spreadsheet?
You can do this in R:
nums = rep(1:4, 5)
sample(nums)
Repeat as necessary.
posted by one_bean at 1:07 PM on February 9, 2014
nums = rep(1:4, 5)
sample(nums)
Repeat as necessary.
posted by one_bean at 1:07 PM on February 9, 2014
There are at least a couple of ways to do this using random.org, a neat web site that lets you generate list of random numbers:
1) Use their "list randomizer". Enter this list (with one number on each line): "1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 4 4 4 4 4". Then randomize! (Use advanced mode to get results as a "bare bones text document")
2) Use their card shuffler. Create a deck with five sets of cards from 1 (ace) to 5. Shufffle! Here are results.
posted by ManInSuit at 1:13 PM on February 9, 2014
1) Use their "list randomizer". Enter this list (with one number on each line): "1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 4 4 4 4 4". Then randomize! (Use advanced mode to get results as a "bare bones text document")
2) Use their card shuffler. Create a deck with five sets of cards from 1 (ace) to 5. Shufffle! Here are results.
posted by ManInSuit at 1:13 PM on February 9, 2014
Thanks! I figured there was an easy way to this, but didn't know the term was list shuffling. Any one of these methods should work.
posted by codacorolla at 1:30 PM on February 9, 2014
posted by codacorolla at 1:30 PM on February 9, 2014
The term comes from "shuffling a deck of cards". Same usage.
posted by Chocolate Pickle at 1:49 PM on February 9, 2014
posted by Chocolate Pickle at 1:49 PM on February 9, 2014
One more in Python to round things out:
posted by The Michael The at 2:03 PM on February 9, 2014
from random import shuffle
seq = [1]*5 + [2]*5 + [3]*5 + [4]*5
shuffle(seq)
posted by The Michael The at 2:03 PM on February 9, 2014
This thread is closed to new comments.
posted by Nonsteroidal Anti-Inflammatory Drug at 1:00 PM on February 9, 2014