title: Algorithm for finding diversity of a sequence
body: <p>I think there should be an algorithm for this out there so I hope someone can help me out here.</p>
  
  <p>I want to find out a metric that shows diversity in terms of number of unique numbers and transition between two consecutive elements of a given sequence. For example, </p>
  
  <pre><code>sequence-1 = [1,1,2,2,3,3]
  sequence-2 = [1,1,1,1,2,2]
  sequence-3 = [1,2,3,1,3,2]
  sequence-4 = [2,2,2,2,2,2]
  </code></pre>
  
  <p>If I compare based on that metric, the result should look like as follows: </p>
  
  <pre><code>sequence-3 &gt; sequence-1 &gt; sequence-2 &gt; sequence-4 
  </code></pre>
  
  <p>Basically, the criteria getting that result may be something like: </p>
  
  <pre><code>transistion_changes for sequence-1: 2 (1-&gt;2, 2-&gt;3)
  transistion_changes for sequence-2: 1 (1-&gt;2)
  transistion_changes for sequence-3: 5 (1-&gt;2, 2-&gt;3, 3-&gt;1, 1-&gt;3, 3-&gt;2)
  transistion_changes for sequence-4: 0 
  </code></pre>
  
  <p><strong>Is there an algorithm in literature does the same thing?</strong>  </p>