for link in G: times += G[link] if test: times_test = [] for link in G_test: times_test += G_test[link] times = np.sort(times) if test: times_test = np.sort(times_test) ## Build the MEG model m = meg.meg_model(G, verbose=False, tau_zero=tau_zero, full_links=full_links, discrete=True) m.specification(main_effects=main_effects, interactions=interactions, poisson_me=poisson_main_effects, poisson_int=poisson_interactions, hawkes_me=hawkes_main_effects, hawkes_int=hawkes_interactions, D=D, verbose=False) np.random.seed(117711) m.prior_initialisation() ## Initialise all to the same values init_i = np.array([Counter(m.ni)[x] / m.T / m.n + 1e-9 for x in range(m.n)])
## Empty matrix A = {} for i in range(n): for j in range(n): A[i, j] = [1] ## Simulate np.random.seed(S) G = {} for i in range(nsim): ## MEG model setup for simulation m = meg.meg_model(A, tau_zero=True, full_links=True, verbose=False, discrete=False, force_square=True, evaluate_directed=False) m.specification(main_effects=False, interactions=True, poisson_me=False, poisson_int=False, hawkes_me=True, hawkes_int=True, D=1, verbose=False) m.prior_initialisation() ## True values of the parameters m.gamma = np.array([0.1, 0.5]) m.gamma_prime = np.array([0.1, 0.3])
## Remove repeated observations times = np.sort(np.unique([float(x) for x in line[2:]])) times = times[times > tmin] - tmin times_test = times[np.logical_and(times >= 86400 * 14, times < 86400 * 21)] if comp in huxley_map and host in server_map and len( times_test) > 0: if (huxley_map[comp], server_map[host]) in G_test: G_test[huxley_map[comp], server_map[host]] += list(times_test) else: G_test[huxley_map[comp], server_map[host]] = list(times_test) ## Build the MEG model m = meg.meg_model(G, verbose=False) m.specification(main_effects=main_effects, interactions=interactions, poisson_me=poisson_main_effects, poisson_int=poisson_interactions, hawkes_me=hawkes_main_effects, hawkes_int=hawkes_interactions, D=D, verbose=False) np.random.seed(117711) ## Prior initialisation m.prior_initialisation() ## Initialise init_i = np.array([Counter(m.ni)[x] / m.T / m.n1 + 1e-9 for x in range(m.n1)]) init_j = np.array(
hawkes_main_effects = True if args.hawkes_main_effects else False hawkes_interactions = True if args.hawkes_interactions else False D = args.d eta = args.eta N_nodes = args.n ## Parse arguments G = {} j = 0 A = np.load(input_folder + '/graphs.npy', allow_pickle='TRUE').item() for index in A: G[j] = A[index] j += 1 ## Model m = meg.meg_model(G[0], tau_zero=True, verbose=False, discrete=False, force_square=True) ## Extract n m.n = N_nodes ## Repeat initialisations 5 times ks_scores = []; ks_pvals = [] if main_effects: alpha = np.zeros((j,N_nodes)); beta = np.zeros((j,N_nodes)) if not poisson_main_effects: mu = np.zeros((j,N_nodes)); phi = np.zeros((j,N_nodes)) mu_prime = np.zeros((j,N_nodes)); phi_prime = np.zeros((j,N_nodes)) if interactions: if D == 1: gamma = np.zeros((j,N_nodes)); gamma_prime = np.zeros((j,N_nodes)) nu = np.zeros((j,N_nodes)); nu_prime = np.zeros((j,N_nodes))