summaryrefslogtreecommitdiffstats
path: root/hawkes/data2.py
diff options
context:
space:
mode:
authorThibaut Horel <thibaut.horel@gmail.com>2015-09-12 16:37:44 -0400
committerThibaut Horel <thibaut.horel@gmail.com>2015-09-12 16:37:44 -0400
commitbfae098bbc47b3948a2a794bee4e49ff32504d6b (patch)
treefcd344ae14be1519acb2649157252e5fa0ae4aea /hawkes/data2.py
parent717e7f2edda52100406d17826bd617b7915c5daf (diff)
downloadcriminal_cascades-bfae098bbc47b3948a2a794bee4e49ff32504d6b.tar.gz
Incorporate the time varying model for the background rate
Diffstat (limited to 'hawkes/data2.py')
-rw-r--r--hawkes/data2.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/hawkes/data2.py b/hawkes/data2.py
index c091e7a..b8f83c9 100644
--- a/hawkes/data2.py
+++ b/hawkes/data2.py
@@ -2,6 +2,7 @@ from csv import DictReader
import sys
from itertools import product
from cPickle import dump
+from math import cos
MAX_TIME = 3012
@@ -10,13 +11,18 @@ def parse(s):
return None if s == "NA" else int(float(s))
+def fluctuation_int(t):
+ if t is None:
+ t = MAX_TIME
+ return t + 0.43 / 0.0172 * (cos(4.36) - cos(0.0172 * t + 4.36))
+
+
def load_nodes(filename):
with open(filename) as fh:
reader = DictReader(fh)
d = {parse(row["name"]): parse(row["fatal_day"]) for row in reader}
for n, t in d.iteritems():
- if t is None:
- d[n] = MAX_TIME
+ d[n] = fluctuation_int(t)
return d