def SampleSum ( dists , n ) : pmf = MakePmfFromList ( RandomSum ( dists ) for i in xrange ( n ) ) return pmf
python random sample based on pmf
Draws a sample of sums from a list of distributions .
def SampleSum(dists, n):
    """Draws a sample of sums from a list of distributions.

    dists: sequence of Pmf or Cdf objects
    n: sample size

    returns: new Pmf of sums
    """
    pmf = MakePmfFromList(RandomSum(dists) for i in xrange(n))
    return pmf