How do you draw/visualize a combination table?

1.4k Views Asked by At

This is somewhat related to a previous question I asked

I have three variables in a programming function, and a 4th variable depends on these. I have to test the dependent variable against all combinations of the three variables:

  • Var A: 2 possible values
  • Var B: 3 possible values
  • Var C: 5 possible values

Now I know that there are 30 combinations of these three variables (2x3x5), but how do I draw this in table form?

If each variable was binary, I could draw a truth table: 000, 001, 010 etc. But is there an equivalent system for the combination I have detailed here?

Regards

Brian

2

There are 2 best solutions below

1
On BEST ANSWER

Excel is not the end of the world. You have a three-dimensional array, and if you want to render its three-dimensional structure "graphically" there is no other way than to draw "perspectively" a $2\cdot 3\cdot5$ lattice of black dots, and to annotate each of these dots with the intended value $f(A,B,C)$. As $A$ can take only two different values the $30$ dots come in two layers à $3\cdot5$ dots, which might simplify the figure.

Given that there are only $30$ values of the independent variable $(A,B,C)$ you can as well list them in lexicographic order $$(a_1,b_1,c_1), \ (a_1,b_1,c_2),\ldots, \ (a_1,b_1,c_5),\ (a_1,b_2,c_1),\ldots,\ (a_1,b_2,c_5), \ldots, \ (a_2,b_3,c_5)\ ,$$ and every reader will be able to follow step for step.

1
On

It's unclear to me whether you're asking for an algorithm for a computer to generate all possibilities, or a way for a human to write them down and not miss any, or a way for a human to draw an appealing picture that represents the possibilities.

One common method for this sort of thing is to use a tree diagram, as depicted at http://www.mathsisfun.com/data/basic-counting-principle.html. They sometimes are used in probability problems, as depicted in this image by Kjell Magne Fauske found here on TeXample.net:

probability tree

Another general method for listing would be to use letters (or numbers, or whatever you like) like "a" and "b" for the A possibilities, "a" and "b" and "c" for B, and "a" through "e" for C. Then write the 30 fake words in alphabetical order to make sure you don't miss any: "aaa","aab","aac","aad","aae","aba",…


Finally, if you're writing a computer program to list all the possibilities, there are lots of different ways depending on the language. For instance, the Haskell code putStr$unlines [['A',a,'B',b,'C',c]|a<-['1'..'2'],b<-['1'..'3'],c<-['1'..'5']] and the Mathematica code t=ToString;Map[Print,Flatten[Table[Table[Table["A"<>t[a]<>"B"<>t[b]<>"C"<>t[c],{c,1,5}],{b,1,3}],{a,1,2}]]]; both produce lines like "A1B1C1", "A1B1C2",... with one possibility on each line.

In Scratch, code that does something very similar would be:scratch code

You can see it in action here.