title: Sum of products of pairs in a list
body: <p>This is the problem I have. Given a list </p>
  
  <pre><code>xList = [9, 13, 10, 5, 3]
  </code></pre>
  
  <p>I would like to calculate for sum of each element multiplied by subsequent elements </p>
  
  <pre><code>sum([9*13, 9*10, 9*5 , 9*3]) + 
  sum([13*10, 13*5, 13*3]) + 
  sum([10*5, 10*3]) + 
  sum ([5*3])
  </code></pre>
  
  <p>in this case the answer is <strong>608</strong>.</p>
  
  <p>Is there a way to do this perhaps with <code>itertools</code> or natively with <code>numpy</code>? </p>
  
  <p>Below is a function I came up with. It does the job but it is far from ideal as I would like to add other stuff as well. </p>
  
  <pre><code>    def SumProduct(xList):
          ''' compute the sum of the product 
          of a list 
          e.g. 
          xList = [9, 13, 10, 5, 3]
          the result will be 
          sum([9*13, 9*10, 9*5 , 9*3]) + 
          sum([13*10, 13*5, 13*3]) + 
          sum([10*5, 10*3]) + 
          sum ([5*3])
          '''
          xSum = 0
          for xnr, x in enumerate(xList):
              #print xnr, x
              xList_1 = np.array(xList[xnr+1:])
              #print x * xList_1
              xSum = xSum + sum(x * xList_1)
          return xSum
  </code></pre>
  
  <p>Any help appreciated. </p>
  
  <p>N.B: In case you wonder, I am trying to implement <a href="http://repository.upenn.edu/cgi/viewcontent.cgi?article=1043&amp;context=asc_papers" rel="nofollow">Krippendorf's alpha</a> with <strong>pandas</strong></p>