I want to use Tuples
(if you know better way please let me know) to create the sample space for some events. Assume that I have 2 events each of which can change to a known number (in the case of a coin it is 2). I want to get all of the possible combinations. Something like this:
{0 0} {0 1} {1 0} {1 1}
I can use nested for loop but prefer to not.
I used Tuples
and Do
(see the code below), but it does not give the right answer. What is the problem?
sampleSpaces =
TableForm[Tuples[{i, j}, 2]]], {i, 0, 1}, {j, 0, 1}];
Table
is what you wanted here.TableForm
is a formatting wrapper, and should not be used in these cases, only to do visual formatting. $\endgroup$sampleSpaces = Table[Tuples[{i, j, k}, 3], {i, 0, 2}, {j, 0, 2}, {k, 0, 2}]
and let us know if it works? $\endgroup$Tuples[{0, 1}, 2]
? $\endgroup$RandomChoice[Tuples[{0, 1}, 2], 10]
? $\endgroup$