generating list for joint distribution
Question: I'm pretty sure this is an easy problem but I am completely blacking out on
how to fix this. I am trying to work my way through the PGM class on coursera
and it starts of with joint probability distribution. So I am trying to
generate a list of all possible distributions given n variables, where each
variable can take on some discrete value between 0...z

so for instance say we have 3 variables, and each can take on values of just 0
and 1 I want to generate this:

    
    
    [[0, 0, 1]
    [0, 1, 0]
    [1, 0, 0]
    [1, 1, 0]
    [0, 1, 1]
    [1, 1, 1]
    [1, 0, 1]
    [0, 0, 0]]
    

I am working in python I am drawing a blank on how to dynamically generate
this.


Answer: If you prefer list comprehension:

    
    
    [[a, b, c] for a in range(2) for b in range(2) for c in range(2)]
    

And I forgot to mention that you can use pprint to get the effect you want:

    
    
    >>> import pprint  
    >>> pprint.pprint([[a, b, c] for a in range(2) for b in range(2) for c in range(2)])  
    [[0, 0, 0],  
     [0, 0, 1],  
     [0, 1, 0],  
     [0, 1, 1],  
     [1, 0, 0],  
     [1, 0, 1],  
     [1, 1, 0],  
     [1, 1, 1]]  
    >>>   
    

