title: sliding window with priority sampling
body: <p>I have a python list and I need to create from this a sliding window with priority sampling.
  In specific,the list(created from a json file) is the following:</p>
  
  <blockquote>
    <p>print jfile['id']=></p>
  </blockquote>
  
  <pre><code>445860938797707000
  445860940027006000
  445860940144463000
  445860940907819000
  445860941289492000
  445860942677803000
  445860943072067000
  445860944347136000
  445860944791740000
  445860944778768000
  </code></pre>
  
  <p>the code i use for the sliding window is:</p>
  
  <pre><code>numData=100
  
  stream1=np.random.random(numData)
  </code></pre>
  
  <p><code>def prioritySampling (stream, sampleSize):</code></p>
  
  <pre><code>sample=np.zeros(sampleSize)
  tags=np.zeros(sampleSize)
  
  i=0
  j=0
  while i&lt;len(stream):
      if i&lt;sampleSize:
          sample[i] = stream[i]
          tags[i] = np.random.random()
      else:
          newTag = np.random.random()
          maxTag = np.max(tags)
          idxMaxTag = np.argmax(tags)
  
          if maxTag &gt; newTag:
              sample[idxMaxTag]=stream[i]
              tags[idxMaxTag]=newTag
              j=j+1
      i=i+1
  print 'updates priority=',j    
  return sample
  
  
  sampleP1 = prioritySampling (stream1, 10)
  
  p1 = np.array (sampleP1)
  </code></pre>
  
  <p>This works fine in random numbers.
  What if I need to use the list as I showed before?
  Bear in mind that the list originally has about 35.000 ids and I want to have in the end the 10 most popular ids.
  That is, that some ids are presented many times</p>