class_docstr: This class is used for performing non parametric estimation of
  multi-dimensional marked Hawkes processes based on conditional laws.
  
  Marked Hawkes processes are point processes defined by the intensity:
  
  .. math::
      \forall i \in [1 \dots D], \quad
      \lambda_i = \mu_i + \sum_{j=1}^D \int \phi_{ij} * f_{ij}(v_j) dN_j
  
  where
  
  * :math:`D` is the number of nodes
  * :math:`\mu_i` are the baseline intensities
  * :math:`\phi_{ij}` are the kernels
  * :math:`v_j` are the marks (considered iid) of the process :math:`N_j`
  * :math:`f_{ij}` the mark functions supposed to be piece-wise constant
    on intervals :math:`I^j(l)`
  
  The estimation is made from empirical computations of
  
  .. math::
      \lim_{\epsilon \rightarrow 0}
      E [ (N_i[t + lag + \delta + \epsilon] -
           \Lambda[t + lag + \epsilon]) | N_j[t]=1
      \quad \& \quad
      v_j(t) \in I^j(l) ]
  
  For all the possible values of :math:`i`, :math:`i` and :math:`l`.
  The :math:`lag` is sampled on a uniform grid defined by
  :math:`\delta`: :math:`lag = n * \delta`.
  
  Estimation can be performed using several realizations.
  
  Parameters
  ----------
  claw_method : {'lin', 'log'}, default='lin'
      Specifies the way the conditional laws are sampled. It can be either:
  
      * 'lin' : sampling is linear on [0, max_lag] using sampling period
        delta_lag
      * 'log' : sampling is semi-log. It uses linear sampling on [0, min_lag]
        with sampling period delta_lag and log sampling on [min_lag, max_lag]
        using :math:`\exp(\delta)` sampling period.
  
  delta_lag : `float`, default=0.1
      See claw_methods
  
  min_lag : `float`, default=1e-4
      See claw_methods
  
  max_lag : `float`, default=40
      See claw_methods
  
  quad_method : {'gauss', 'lin', 'log'}, default=gauss
      Sampling used for quadrature
  
      * 'gauss' for gaussian quadrature
      * 'lin' for linear quadrature
      * 'log' for log quadrature
  
  min_support : `float`, default=1e-4
      Start value of kernel estimation. It is used for 'log' quadrature
      method only, otherwise it is set to 0.
  
  max_support : `float`, default=40
      End value of kernel estimation
  
  n_quad : `int` : default=50
      The number of quadrature points between [min_support, max_support]
      used for solving the system.
      Be aware that the complexity increase as this number squared.
  
  n_threads : `int`, default=1
      Number of threads used for parallel computation.
  
      * if `int <= 0`: the number of physical cores available on the CPU
      * otherwise the desired number of threads
  
  Other Parameters
  ----------------
  delayed_component : list of `int`, shape=(n_nodes, ), default=None
      list of node indices corresponding to node that should be delayed
      (to avoid simultaneous jumps of different components which can be a
      problem in the estimation)
  
  delay : `float`
      The delayed used for `delayed_component`. Selected components are
      all delayed with the same value
  
  marked_components : `dict`
      A dictionary that indicates which component is considered as marked
      and what are the corresponding intervals ``I_j(l)``
  
  Attributes
  ----------
  n_nodes : `int`
      Number of nodes of the estimated Hawkes process
  
  n_realizations : `int`
      Number of given realizations
  
  baseline : np.ndarray, shape=(n_nodes,)
      Estimation of the baseline
  
  kernels_norms : np.ndarray, shape=(n_nodes, n_nodes)
      L1 norm matrix of the kernel norms
  
  kernels : list of list
      Kernel's estimation on the quadrature points
  
  mean_intensity : list of `float`
      The estimated mean intensity
  
  symmetries1d : list of 2-tuple
      List of component index pairs for imposing symmetries on the mean
      intensity (e.g, ``[(0,1),(2,3)]`` means that the mean intensity of
      the components 0 and 1 must be the same and the mean intensity of the
      components 2 and 3 also
      Can be set using can be set using the `set_model` method.
  
  symmetries2d : list of 2-tuple of 2-tuple
      List of kernel coordinates pairs to impose symmetries on the kernel
      matrix (e.g., ``[[(0,0),(1,1)],[(1,0),(0,1)]]`` for a bidiagonal
      kernel in dimension 2)
      Can be set using can be set using the `set_model` method.
  
  mark_functions : list of 2-tuple
      The mark functions as a list (lexical order on i,j and l, see below)
  
  References
  ----------
  Bacry, E., & Muzy, J. F. (2014).
  Second order statistics characterization of Hawkes processes and
  non-parametric estimation. `arXiv preprint arXiv:1401.0903`_.
  
  .. _arXiv preprint arXiv:1401.0903: https://arxiv.org/pdf/1401.0903.pdf
docstr: Allows to add some more realizations before estimation is performed.
  
  It updates the conditional laws (stored in `self._claw` and
  `self._claw1`) and of the mean intensity (in `self._mean_intensity`).
  
  Parameters
  ----------
  realization : list of `np.narrays` or list of 2-tuple of `np.arrays`
  
      * list of `np.narrays`, shape=(N) , representing the arrival times
        of each component
      * list of pairs (t,m) np.arrays representing the arrival times of
        each component (x) and the cumulative marks signal (m)
  
  T : `double`, default=None
      The duration (in physical time) of the realization. If it is -1 then
      T is considered to be the time of the last event (of any component).
  
  compute : `bool`, default=`False`
      Computes kernel estimation. If set to `False`, you will have to
      manually call `compute` method afterwards.
      This is useful to add multiple realizations and compute only once
      all conditional laws have been updated.
docstr_tok: ["Allows","to","add","some","more","realizations","before","estimation","is","performed",".","It","updates","the","conditional","laws","(","stored","in","`","self._claw","`","and","`","self._claw1","`",")","and","of","the","mean","intensity","(","in","`","self._mean_intensity","`",")",".","Parameters","--","--","--","--","--","realization",":","list","of","`","np.narrays","`","or","list","of","2-tuple","of","`","np.arrays","`","*","list","of","`","np.narrays","`",",","shape=","(","N",")",",","representing","the","arrival","times","of","each","component","*","list","of","pairs","(","t",",","m",")","np.arrays","representing","the","arrival","times","of","each","component","(","x",")","and","the","cumulative","marks","signal","(","m",")","T",":","`","double","`",",","default=None","The","duration","(","in","physical","time",")","of","the","realization",".","If","it","is","-1","then","T","is","considered","to","be","the","time","of","the","last","event","(","of","any","component",")",".","compute",":","`","bool","`",",","default=","`","False","`","Computes","kernel","estimation",".","If","set","to","`","False","`",",","you","will","have","to","manually","call","`","compute","`","method","afterwards",".","This","is","useful","to","add","multiple","realizations","and","compute","only","once","all","conditional","laws","have","been","updated","."]
code: def incremental_fit(self, realization, T=None, compute=True):
      """Allows to add some more realizations before estimation is performed.
  
      It updates the conditional laws (stored in `self._claw` and
      `self._claw1`) and of the mean intensity (in `self._mean_intensity`).
  
      Parameters
      ----------
      realization : list of `np.narrays` or list of 2-tuple of `np.arrays`
  
          * list of `np.narrays`, shape=(N) , representing the arrival times
            of each component
          * list of pairs (t,m) np.arrays representing the arrival times of
            each component (x) and the cumulative marks signal (m)
  
      T : `double`, default=None
          The duration (in physical time) of the realization. If it is -1 then
          T is considered to be the time of the last event (of any component).
  
      compute : `bool`, default=`False`
          Computes kernel estimation. If set to `False`, you will have to
          manually call `compute` method afterwards.
          This is useful to add multiple realizations and compute only once
          all conditional laws have been updated.
      """
      # If first realization we perform some init
      if self.n_realizations == 0:
          realization = self._init_basics(realization)
          self._init_marked_components()
          self._init_index()
          self._init_mark_stats()
          self._init_lambdas()
          self._init_claws()
  
      else:
          if compute and self._has_been_computed_once():
              warnings.warn(
                  (
                      "compute() method was already called, "
                      "computed kernels will be updated."
                  )
              )
  
      # We perform some checks
      if self.n_nodes != len(realization):
          msg = (
              "Bad dimension for realization, should be %d instead of %d"
              % (self.n_nodes, len(realization))
          )
          raise ValueError(msg)
  
      # Realization normalization
      if not isinstance(realization[0], (list, tuple)):
          realization = [
              (r, np.arange(len(r), dtype=np.double) + 1)
              for r in realization
          ]
  
      # Do we need to delay the realization ?
      if self.delayed_component:
          old_realization = realization
          realization = []
          for i in range(0, self.n_nodes):
              if any(self.delayed_component == i):
                  if len(old_realization[i][0]) == 0:
                      realization.append(old_realization[i])
                  else:
                      realization.append(
                          (
                              old_realization[i][0] + self.delay,
                              old_realization[i][1],
                          )
                      )
              else:
                  realization.append(old_realization[i])
  
      # We compute last event time
      last_event_time = -1
      for i in range(0, self.n_nodes):
          if len(realization[i][0]) > 0:
              last_event_time = max(
                  realization[i][0][-1], last_event_time
              )
  
      # If realization empty --> return
      if last_event_time < 0:
          warnings.warn(
              "An empty realization was passed. No computation was performed."
          )
          return
  
      # We set T if needed
      if T is None:
          T = last_event_time
      elif T < last_event_time:
          raise ValueError(
              "Argument T (%g) specified is too small, "
              "you should use default value or a value "
              "greater or equal to %g." % (T, last_event_time)
          )
  
      # We update the mark probabilities and min-max
      for i in range(0, self.n_nodes):
          if len(realization[i][0]) == 0:
              continue
          # We have to take into account the first mark
          der = np.hstack(
              [realization[i][1][0], np.diff(realization[i][1])]
          )
          total = 0
          self._mark_min[i] = min(self._mark_min[i], np.min(der))
          self._mark_max[i] = max(self._mark_max[i], np.max(der))
  
          for l, interval in enumerate(self.marked_components[i]):
              self._mark_probabilities_N[i][l] += np.sum(
                  (der >= interval[0]) & (der < interval[1])
              )
              total += self._mark_probabilities_N[i][l]
  
          for l, interval in enumerate(self.marked_components[i]):
              self._mark_probabilities[i][l] = (
                  self._mark_probabilities_N[i][l] / total
              )
          der[:] = 1
  
      # We update the Lambda
      for i in range(0, self.n_nodes):
          if len(realization[i][0]) <= 0:
              continue
          self._lam_N[i] += len(realization[i][0])
          self._lam_T[i] += T
          self.mean_intensity[i] = self._lam_N[i] / self._lam_T[i]
  
      # We update the _n_events of component i
      # Warning : we don't take care of marks for this computation
      # normally we should do this computation independantly for each mark
      for i in range(0, self.n_nodes):
          good = np.sum(realization[i][0] <= T - self._lags[-1])
          bad = len(realization[i][0]) - good
          self._n_events[0, i] += good
          self._n_events[1, i] += bad
  
      # We might want to use threads, since this is the time consuming part
      with_multi_processing = self.n_threads > 1
      if with_multi_processing:
          pool = ThreadPool(with_lock=True, max_threads=self.n_threads)
          self._set("_lock", pool.lock)
  
      for index, (i, j, l) in enumerate(self._index2ijl):
          if with_multi_processing:
              pool.add_work(
                  self._PointProcessCondLaw,
                  realization,
                  index,
                  i,
                  j,
                  l,
                  T,
              )
          else:
              self._PointProcessCondLaw(realization, index, i, j, l, T)
  
      if with_multi_processing:
          pool.start()
  
      # Here we compute the G^ij (not conditioned to l)
      # It is recomputed each time
      self._claw1 = []
      for i in range(0, self.n_nodes):
          self._claw1.append([])
          for j in range(0, self.n_nodes):
              index = self._ijl2index[i][j][0]
              self._claw1[i].append(np.copy(self._claw[index]))
              self._claw1[i][j] *= self._mark_probabilities[j][0]
              for l in range(1, len(self._ijl2index[i][j])):
                  index = self._ijl2index[i][j][l]
                  self._claw1[i][j] += (
                      self._claw[index] * self._mark_probabilities[j][l]
                  )
  
      self.n_realizations += 1
  
      # Deal with symmetrization
      for i, j in self.symmetries1d:
          t = (self.mean_intensity[i] + self.mean_intensity[j]) / 2
          self.mean_intensity[i] = t
          self.mean_intensity[j] = t
  
          t = (self._mark_min[i] + self._mark_min[j]) / 2
          self._mark_min[i] = t
          self._mark_min[j] = t
  
          t = (self._mark_max[i] + self._mark_max[j]) / 2
          self._mark_max[i] = t
          self._mark_max[j] = t
  
          if self.marked_components[i] != self.marked_components[j]:
              continue
          for l in range(0, len(self.marked_components[i])):
              t = (
                  self._mark_probabilities_N[i][l]
                  + self._mark_probabilities_N[j][l]
              ) / 2
              self._mark_probabilities_N[i][l] = t
              self._mark_probabilities_N[j][l] = t
  
              t = (
                  self._mark_probabilities[i][l]
                  + self._mark_probabilities[j][l]
              ) / 2
              self._mark_probabilities[i][l] = t
              self._mark_probabilities[j][l] = t
  
      for (i1, j1), (i2, j2) in self.symmetries2d:
          t = (self._claw1[i1][j1] + self._claw1[i2][j2]) / 2
          self._claw1[i1][j1] = t
          self._claw1[i2][j2] = t
          if self.marked_components[j1] != self.marked_components[j2]:
              continue
          for l in range(0, len(self.marked_components[j1])):
              index1 = self._ijl2index[i1][j1][l]
              index2 = self._ijl2index[i2][j2][l]
              t = (self._claw[index1] + self._claw[index2]) / 2
              self._claw[index1] = t
              self._claw[index2] = t
  
      # We can remove the thread lock (lock disallows pickling)
      self._set("_lock", None)
  
      if compute:
          self.compute()
  
imports: import itertools
  import sys
  import warnings
  import numpy
  from numpy.polynomial.legendre import leggauss
  from scipy.linalg import solve
  from tick.base import Base, ThreadPool
  from tick.hawkes.inference.build.hawkes_inference import PointProcessCondLaw
label_desc: Use image node_id 12 for calling the HawkesConditionalLaw obj's underlying member method code with example usage: obj.incremental_fit(realization, T, compute) without return types