-
Notifications
You must be signed in to change notification settings - Fork 0
/
simulate_base_data.py
57 lines (49 loc) · 2 KB
/
simulate_base_data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import pandas as pd
import numpy as np
from datetime import datetime, timedelta
# Auxiliar functions
def campaign_new_users(campaign):
return np.round(np.max([np.power(campaign / 200, 2) + np.random.uniform(-10,10,1)[0], 0]))
def network_new_users(users):
return np.round((users / 500) + np.random.uniform(-10,10,1)[0])
def camapign_variation(campaign):
return campaign * (1 + np.random.uniform(-0.1,0.1,1)[0])
# Time handle values
today = datetime.now()
date = today - timedelta(days = 700)
period = 7 # number of days
# Base values
data = pd.DataFrame()
money_users = 0
sudsidy_users = 0
campaign = 1000
# Auxiliari settings
np.random.seed(0)
ready = False
while not ready:
# ------ Period Simulation -------
# In this case, money size increase by network effects based on sudsidy size
money_size_campaign = campaign_new_users(campaign)
sudsidy_size_campaign = campaign_new_users(campaign)
money_size_network = network_new_users(sudsidy_users)
sudsidy_size_network = network_new_users(sudsidy_users)
data = data.append(pd.DataFrame({
"date" : date,
"money_size_users" : money_users + money_size_campaign + money_size_network,
"subsidy_size_users" : sudsidy_users + sudsidy_size_campaign + sudsidy_size_network,
"money_size_new_users_by_campaign" : money_size_campaign,
"money_size_new_users_by_network" : money_size_network,
"subsidy_size_new_users_by_campaign" : sudsidy_size_campaign,
"subsidy_size_new_users_by_network" : sudsidy_size_network,
"investement_in_money_size_campaigns" : campaign,
"investement_in_sudsidy_size_campaigns" : campaign
}, index = {date}))
# ------- Variables update --------
money_users += money_size_campaign + money_size_network
sudsidy_users += sudsidy_size_campaign + sudsidy_size_network
campaign = camapign_variation(campaign)
date += timedelta(days = period)
ready = date >= today
print(data.tail())
print(data.shape)
data.to_csv("data/test_data.csv", index = False)