def test_simu_hawkes_multi_attrs(self): """...Test multiple simulations via SimuHawkesMulti vs. single Hawkes See that multiple simulations has same attributes as a single Hawkes simulation, but different results """ hawkes = SimuHawkes(kernels=self.kernels, baseline=self.baseline, end_time=10, verbose=False, seed=504) multi = SimuHawkesMulti(hawkes, n_threads=4, n_simulations=10) multi.simulate() hawkes.simulate() np.testing.assert_array_equal(hawkes.simulation_time, multi.simulation_time) np.testing.assert_array_equal(hawkes.n_nodes, multi.n_nodes) np.testing.assert_array_equal(hawkes.end_time, multi.end_time) np.testing.assert_array_equal(hawkes.max_jumps, multi.max_jumps) np.testing.assert_array_equal(hawkes.spectral_radius(), multi.spectral_radius) self.assertTrue( all( np.array_equal(hawkes.mean_intensity(), np.array(x)) for x in multi.mean_intensity)) self.assertFalse( np.array_equal(hawkes.n_total_jumps, multi.n_total_jumps))
def test_hawkes_mean_intensity(self): """...Test that Hawkes obtained mean intensity is consistent """ hawkes = SimuHawkes(kernels=self.kernels, baseline=self.baseline, seed=308, end_time=300, verbose=False) self.assertLess(hawkes.spectral_radius(), 1) hawkes.track_intensity(0.01) hawkes.simulate() mean_intensity = hawkes.mean_intensity() for i in range(hawkes.n_nodes): self.assertAlmostEqual(np.mean(hawkes.tracked_intensity[i]), mean_intensity[i], delta=0.3)