import math
import random
from scipy.integrate import simps
# Function that calculates number of new and returning visitors per day in to a list
# Includes a condition to push new players based on press releases
def dailyvisits(days, pressdates):
start = 5000
newplayers = start
visits = []
presspush = 0
for i in days:
# On day one all players are new players
if i == 0:
np = start # new players
rp = 0 # returning players
# From day two calculate decay and other press pushes
else:
# Press release brings additional new players
# But the addtional players are inverse to time since the release
# Has reached the maximum interested people or loss of novelty??
if i in press:
presspush = start*10/i
np = start*math.pow(i,-1.303) + presspush # new players
rp = (start/5)*math.pow(i,-0.764) # returning players
# 12 minutes per new player and 70 minutes per returning player
# visists appended are number of human processing hours contributed
v = round((np*12) + (rp*70))
visits.append(v/60)
# press pushes are exponentially decayed and are reset to zero
presspush = presspush*math.exp(-0.6)
if presspush < 0:
presspush = 0
return visits
days=range(1,359)
press=[]
visits1 = dailyvisits(days, press)
total1 = sum(visits1)/24
f = open('visit_fraxinus_model.txt', 'w')
print >> f, "Day\tPlayers\tType"
for k in days:
print >> f, days[k-1], "\t", visits1[k-1], "\tFraxinus_no_press"
print "Number of days contributed without press releases", total1
Number of days contributed without press releases 785.991666667
press=[9,42,86,90,167]
visits2 = dailyvisits(days, press)
total2 = sum(visits2)/24
for k in days:
print >> f, days[k-1], "\t", visits2[k-1], "\tFraxinus_with_press"
print "Number of days contributed with press releases", total2
Number of days contributed with press releases 936.098611111
# Function that calculates number of new and returning visitors per day in to a list
# Includes a condition to push new players based on press releases
def progvisits(days, pressdates, invites):
# Adjust start to a small number and push it max over period of 2 months
start = 10
newplayers = start
visits = []
presspush = 0
for i in days:
# On day one all players are new players
if i == 0:
np = start # new players
rp = 0 # returning players
# From day two calculate decay and other press pushes
else:
# Press release brings additional new players
# But the addtional players are inverse to time since the release
# Has reached the maximum interested people or loss of novelty??
if i in press:
presspush = newplayers*invites/(i*0.5)
if start <= 5000:
newplayers = presspush
start += presspush
#print presspush
np = start*math.pow(i,-1.303) + presspush # new players
rp = (start/5)*math.pow(i,-0.764) # returning players
# 12 minutes per new player and 70 minutes per returning player
# visists appended are number of human processing hours contributed
v = round((np*12) + (rp*70))
visits.append(v/60)
presspush = presspush*math.exp(-0.6)
if presspush < 0:
presspush = 0
return visits
press=range(2,19)
invites = 3
visits3 = progvisits(days, press, invites)
total3 = sum(visits3)/24
for k in days:
print >> f, days[k-1], "\t", visits3[k-1], "\tProgress-3players"
print "Number of days contributed with press releases", total3
Number of days contributed with press releases 84.1645833333
press=range(2,19)
invites = 10
visits4 = progvisits(days, press, invites)
total4 = sum(visits4)/24
for k in days:
print >> f, days[k-1], "\t", visits4[k-1], "\tProgress-10players"
print "Number of days contributed with press releases", total4
Number of days contributed with press releases 5091.41875
press=[2,5,9,14,18,25,37,42,48,56,65,72,86,90,102,110,135,167]
invites = 3
visits5 = progvisits(days, press, invites)
total5 = sum(visits5)/24
for k in days:
print >> f, days[k-1], "\t", visits5[k-1], "\tRandom-3players"
print "Number of days contributed with press releases", total5
Number of days contributed with press releases 15.7222222222
press=[2,5,9,14,18,25,37,42,48,56,65,72,86,90,102,110,135,167]
invites = 10
visits6 = progvisits(days, press, invites)
total6 = sum(visits6)/24
for k in days:
print >> f, days[k-1], "\t", visits6[k-1], "\tRandom-10players"
print "Number of days contributed with press releases", total6
f.close()
Number of days contributed with press releases 665.90625
import matplotlib.pyplot as plt
fig, axes = plt.subplots(1, 1, figsize=(16, 8))
plt.plot(days, visits1, "+", label="Fraxinus - no press after release")
plt.plot(days, visits2, "-", label="Fraxinus - with press releases")
plt.plot(days, visits3, "--v", label="each player invites 3 players during intial period")
plt.plot(days, visits4, "--^", label="each player invites 10 players during intial period")
plt.plot(days, visits5, "-->", label="each player invites 3 players at selected time points")
plt.plot(days, visits6, "--", label="each player invites 10 players at selected time points")
plt.yscale('log')
#plt.xscale('log')
plt.xlabel('Days', fontsize=14)
plt.ylabel('Number of human processing hours', fontsize=14)
plt.title('Time line of human processing contributed', fontsize=24)
plt.legend()
<matplotlib.legend.Legend at 0x10df25f90>