Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Let's say I want to find a sample space of such experiment: There are three exits from the box: Left (L), right (R) and front (F). Three mice have been put in that box. Find the sample space of an event which mouse has chosen which exit. Function Permutations[] gives all different outputs.


How can I find also outcomes like {F,F,L}, {R,R,R}... ?

share|improve this question

closed as too localized by Ajasja, belisarius, Verbeia Feb 18 '13 at 14:59

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

It's only terminology. The OP has to state if he/she wants variations or combinations. (In other words: Is (LLF) the same as (LFL)?) –  Stefan Feb 18 '13 at 14:48
yep, sounds like he wants Tuples and is confused about the meaning of Permutations –  Szabolcs Feb 18 '13 at 14:53
@Ajasja When I use your example, I don't get the event {RRR} which the OP demanded. So Permutations does NOT give the asked results. –  Stefan Feb 18 '13 at 15:02
@Misery Please try to re-state your question in an easier to understand way, to avoid all these close and reopen votes. I'd suggest giving an example input and the complete output your desire. –  Szabolcs Feb 18 '13 at 15:10
Question should be restated as: Given a list of 3 distinct objects, how does one form the list of all possible triples of these objects, repetitions allowed? –  murray Feb 18 '13 at 15:17

2 Answers 2

up vote 6 down vote accepted
 Tuples[{l, r, f}, 3]
 (* {{l, l, l}, {l, l, r}, {l, l, f}, {l, r, l}, {l, r, r}, {l, r, f}, 
    {l, f, l}, {l, f, r}, {l, f, f}, {r, l, l}, {r, l, r}, {r, l, f}, 
    {r,  r, l}, {r, r, r}, {r, r, f}, {r, f, l}, {r, f, r}, {r, f, f},
    {f, l,  l}, {f, l, r}, {f, l, f}, {f, r, l}, {f, r, r}, {f, r, f}, 
    {f, f,  l}, {f, f, r}, {f, f, f}} *)


share|improve this answer

The only problem is that you have a recursive definition ( you want L to be a list and outcome).

In general using identifiers that start with a capital letter is best avoided. D and C are some examples of this.

This is much safer and works as expected:

list = {"L", "R", "F"}

If you would like to have "permutations with repetition" then Tuples is the right tool for the job (as kguler already noted):

Tuples[list, 3]
share|improve this answer
And E, and I, and N, and O... –  belisarius Feb 18 '13 at 14:38

Not the answer you're looking for? Browse other questions tagged or ask your own question.