code: def Marginal(self, i, name=''):
          
          pmf = Pmf(name=name)
          for vs, prob in self.Items():
              pmf.Incr(vs[i], prob)
          return pmf
docs: Gets the marginal distribution of the indicated variable.
  
          i: index of the variable we want
  
          Returns: Pmf