Skip to content

Instantly share code, notes, and snippets.

@instance01
Last active July 19, 2020 18:29
Show Gist options
  • Save instance01/06ff712778cc40fece18feacc082cfe5 to your computer and use it in GitHub Desktop.
Save instance01/06ff712778cc40fece18feacc082cfe5 to your computer and use it in GitHub Desktop.
# More information: "A Framework for Clustering Evolving Data Streams", Aggarwal, 2003
# This does not deal with redundancy (which apparently is rampant).
import math
alpha = 2
beta = 2
levels = []
def new_snapshot(tnow):
global levels
height = int(math.log(tnow, alpha) + 1)
print(height)
if len(levels) < height:
levels.insert(0, [])
for level in range(height)[::-1]:
if tnow % (alpha ** level) == 0:
levels[level].append(tnow)
if len(levels[level]) > (alpha ** beta + 1):
levels[level].pop(0)
print(levels)
for i in range(1, 2001):
new_snapshot(i)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment