Last active
August 26, 2016 08:49
"Server Log" simulation generator
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
# | |
# Generates the simulated server log | |
# | |
import csv | |
import numpy as np | |
import random | |
base = 750 | |
amplitude = 500 | |
growth = 1e-6 | |
noise = 20 | |
with open('server-log.csv', 'w', newline='') as csvfile: | |
fieldnames = ['period', 'value'] | |
writer = csv.DictWriter(csvfile, fieldnames) | |
writer.writeheader() | |
for i in range(0, 2016 * 52 * 4): | |
row = {'period': i, 'value': (base * (1 + growth)) + amplitude * np.sin( i * np.pi * 2 / 288 - np.pi / 2) + (random.random() * 2 * noise - noise) } | |
writer.writerow(row) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment