docstr: Test estimation on simulated data from a non-parametric Hawkes model
  
  The test compares the time-integral of Hawkes kernels: 
  expected (i.e. exact, coming from the model used to simulate the data)
  and estimated (i.e. coming from the estimated kernels).
docstr_tok: ["Test","estimation","on","simulated","data","from","a","non-parametric","Hawkes","model","The","test","compares","the","time-integral","of","Hawkes","kernels",":","expected","(","i.e",".","exact",",","coming","from","the","model","used","to","simulate","the","data",")","and","estimated","(","i.e",".","coming","from","the","estimated","kernels",")","."]
code: def test_hawkes_em_fit_3(self):
      """Test estimation on simulated data from a non-parametric Hawkes model
  
      The test compares the time-integral of Hawkes kernels:
      expected (i.e. exact, coming from the model used to simulate the data)
      and estimated (i.e. coming from the estimated kernels).
      """
      simu_model = simulate_hawkes_nonparam_kern(
          end_time=30000,
          seed=2334,
      )
  
      em = HawkesEM(
          kernel_support=4.0,
          kernel_size=32,
          n_threads=8,
          verbose=True,
          max_iter=500,
          tol=1e-6,
      )
      em.fit(simu_model.timestamps)
  
      evaluation_points = np.linspace(0, 4.0, num=10)
      for i in range(2):
          for j in range(2):
              estimated_primitive_kernel_values = (
                  em._compute_primitive_kernel_values(
                      i, j, evaluation_points
                  )
              )
              expected_primitive_kernel_values = simu_model.kernels[
                  i, j
              ].get_primitive_values(evaluation_points)
              self.assertTrue(
                  np.allclose(
                      expected_primitive_kernel_values,
                      estimated_primitive_kernel_values,
                      atol=2e-2,
                      rtol=3.5 - 1,
                  ),
                  f"Kernel[{i}, {j}]: Estimation error\n"
                  f"Estimated values:\n{estimated_primitive_kernel_values}\n"
                  f"Expected values:\n{expected_primitive_kernel_values}\n",
              )
  
imports: import unittest
  import numpy
  from tick.hawkes.inference import HawkesEM
  from tick.hawkes.model.tests.model_hawkes_test_utils import hawkes_intensities, hawkes_log_likelihood
  from tick.hawkes import SimuHawkes, HawkesKernelTimeFunc, HawkesKernelExp, SimuHawkesExpKernels
  from tick.base import TimeFunction
label_desc: Use image node_id 5 for calling the Test obj's underlying member method code with example usage: obj.test_hawkes_em_fit_3() without return types