Created
September 14, 2015 14:52
-
-
Save luke14free/fc695977b5dcffb16b70 to your computer and use it in GitHub Desktop.
Generate pseudo logs for BS test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from scipy import stats | |
import pandas as pd | |
randgen = lambda n: [1 if i > .5 else 0 for i in stats.gamma.rvs(1, scale=0.7, size=n) > .5] | |
def truncate(l, n): | |
try: | |
ls = "".join(map(str, l)) | |
idx = ls.index("".join(map(str, [0] * n))) | |
return l[:idx] + [0] * (len(l) - idx) | |
except ValueError: | |
return l | |
def generate_logs(days=90, users=1000, max_lazyness=5): | |
d = {i: truncate(randgen(days), max_lazyness) for i in range(users)} | |
logs = pd.DataFrame.from_dict(d).transpose() | |
logs.columns = ['Day ' + str(i) for i in range(1, days + 1)] | |
logs.index.name = "User ID" | |
return logs | |
generate_logs().to_csv("logs.csv") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment