aboutsummaryrefslogtreecommitdiffstats
path: root/simulation/main.py
diff options
context:
space:
mode:
Diffstat (limited to 'simulation/main.py')
-rw-r--r--simulation/main.py28
1 files changed, 10 insertions, 18 deletions
diff --git a/simulation/main.py b/simulation/main.py
index 4fa8f6c..c2446d7 100644
--- a/simulation/main.py
+++ b/simulation/main.py
@@ -56,25 +56,17 @@ def build_cascade_list(cascades, collapse=False):
return np.vstack(x), np.vstack(s)
-def cascadeLkl(graph, infect, sus):
- # There is a problem with the current implementation
- # Note that you need to take into account the time diff between the label
- # and the values being conditioned. Note also that the matrix if stacked as
- # such will require to keep track of the state 0 of each cascade.
- a = np.dot(infect, graph)
- return np.log(1. - np.exp(-a[(infect[1:])*sus[1:]])).sum() \
- - a[(~infect[1:])*sus].sum()
-
-
if __name__ == "__main__":
g = np.array([[0, 0, 1], [0, 0, 0.5], [0, 0, 0]])
p = 0.5
g = np.log(1. / (1 - p * g))
- cascades = simulate_cascades(100, g)
- cascade, y_obs = mn.build_matrix(cascades, 0)
- conf = mn.bootstrap(x, y, n_iter=100)
-
- estimand = np.linalg.norm(np.delete(conf - g[0], 0, axis=1), axis=1)
- error.append(mn.confidence_interval(*np.histogram(estimand, bins=50)))
- plt.semilogx(sizes, error)
- plt.show()
+ error = []
+ sizes = [10, 10**2, 10**3]
+ for s in sizes:
+ cascades = simulate_cascades(s, g)
+ cascade, y_obs = mn.build_matrix(cascades, 0)
+ conf = mn.bootstrap(cascade, y_obs, n_iter=100)
+ estimand = np.linalg.norm(np.delete(conf - g[0], 0, axis=1), axis=1)
+ error.append(mn.confidence_interval(*np.histogram(estimand, bins=50)))
+ plt.semilogx(sizes, error)
+ plt.show()