summaryrefslogtreecommitdiffstats
path: root/hawkes/cause.py
diff options
context:
space:
mode:
Diffstat (limited to 'hawkes/cause.py')
-rw-r--r--hawkes/cause.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/hawkes/cause.py b/hawkes/cause.py
new file mode 100644
index 0000000..0cce9d2
--- /dev/null
+++ b/hawkes/cause.py
@@ -0,0 +1,24 @@
+from cPickle import load
+from math import exp
+
+
+def main(a):
+ lamb, alpha, mu = a
+ dr = 0
+ r = 0
+ for ((n1, t1), s) in event_edges.iteritems():
+ if not s:
+ dr += 1
+ if lamb > sum(alpha * w * mu * exp(-mu * (t1 - t2))
+ for (n2, t2, w) in s):
+ r += 1
+ return lamb, alpha, mu, dr, r
+
+
+if __name__ == "__main__":
+ nodes, edges, events, event_edges = load(open("data.pickle", "rb"))
+ for i, line in enumerate(open("values-sorted.txt")):
+ if i > 100:
+ break
+ lamb, alpha, mu, v = map(float, line.strip().split())
+ print main((lamb, alpha, mu))