Skip to content

Instantly share code, notes, and snippets.

@singhpratyush
Last active June 29, 2017 17:27
Show Gist options
  • Save singhpratyush/8292b6fc815e5a18311848f635724f99 to your computer and use it in GitHub Desktop.
Save singhpratyush/8292b6fc815e5a18311848f635724f99 to your computer and use it in GitHub Desktop.
A small code to illustrate the behaviour of how KaizenHarvester from loklak server project
"""
Kaizen Harvester - https://github.com/loklak/loklak_server/blob/development/src/org/loklak/harvester/strategy/KaizenHarvester.java
loklak server project - https://github.com/loklak/loklak_server
"""
import random
from matplotlib import pyplot
m = []
for i in range(101):
fraction = i / 100.
count = 0
for j in range(10000):
n = random.uniform(0, 1)
if n < fraction:
count += 1
m.append((fraction, count))
pyplot.plot(*zip(*m))
pyplot.xlabel("Ratio of queue filled")
pyplot.ylabel("Harvest attempts out of 10,000")
pyplot.title("Harvesting frequency vs. Filled queue ratio")
pyplot.grid(True)
pyplot.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment