parameters: (self, K, prob)
docstring: Computes the distribution of the sum of K independent choices from
          probability distribution prob
docstring_summary: Computes the distribution of the sum of K independent choices from
          probability distribution prob
docstring_tokens: Computes the distribution of the sum of K independent choices from probability distribution prob
function: def sum_dist(self, K, prob):
          """
          Computes the distribution of the sum of K independent choices from
          probability distribution prob
          """
          if K == 0:
              return [1.0]
          elif K == 1:
              return prob
          elif K == 2:
              v = [0.0 for i in range(2*len(prob)-1)]
              for (i, p) in enumerate(prob):
                  for (j, q) in enumerate(prob):
                      v[i+j] += p*q
              return v
          else:
              K1 = K / 2
              K2 = K / 2 + K % 2
              v1 = self.sum_dist(K1, prob)
              v2 = self.sum_dist(K2, prob)
              v = [0.0 for i in range(len(v1)+len(v2)-1)]
              for (i, p) in enumerate(v1):
                  for (j, q) in enumerate(v2):
                      v[i+j] += p*q
              return v
function_tokens: def sum_dist ( self , K , prob ) : if K == 0 : return [ 1.0 ] elif K == 1 : return prob elif K == 2 : v = [ 0.0 for i in range ( 2 * len ( prob ) - 1 ) ] for ( i , p ) in enumerate ( prob ) : for ( j , q ) in enumerate ( prob ) : v [ i + j ] += p * q return v else : K1 = K / 2 K2 = K / 2 + K % 2 v1 = self . sum_dist ( K1 , prob ) v2 = self . sum_dist ( K2 , prob ) v = [ 0.0 for i in range ( len ( v1 ) + len ( v2 ) - 1 ) ] for ( i , p ) in enumerate ( v1 ) : for ( j , q ) in enumerate ( v2 ) : v [ i + j ] += p * q return v