Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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