class_docstr: Hawkes process model exponential kernels with fixed and given decays.
  It is modeled with least square loss:
  
  .. math::
      \sum_{i=1}^{D} \left(
          \int_0^T \lambda_i(t)^2 dt
          - 2 \int_0^T \lambda_i(t) dN_i(t)
      \right)
  
  where :math:`\lambda_i` is the intensity:
  
  .. math::
      \forall i \in [1 \dots D], \quad
      \lambda_i(t) = \mu_i + \sum_{j=1}^D
      \sum_{t_k^j < t} \phi_{ij}(t - t_k^j)
  
  where
  
  * :math:`D` is the number of nodes
  * :math:`\mu_i` are the baseline intensities
  * :math:`\phi_{ij}` are the kernels
  * :math:`t_k^j` are the timestamps of all events of node :math:`j`
  
  and with an exponential parametrisation of the kernels
  
  .. math::
      \phi_{ij}(t) = \alpha^{ij} \beta^{ij}
                     \exp (- \beta^{ij} t) 1_{t > 0}
  
  In our implementation we denote:
  
  * Integer :math:`D` by the attribute `n_nodes`
  * Matrix :math:`B = (\beta_{ij})_{ij} \in \mathbb{R}^{D \times D}` by the
    parameter `decays`. This parameter is given to the model
  
  Parameters
  ----------
  decays : `float` or `numpy.ndarray`, shape=(n_nodes, n_nodes)
      Either a `float` giving the decay of all exponential kernels or
      a (n_nodes, n_nodes) `numpy.ndarray` giving the decays of
      the exponential kernels for all pairs of nodes.
  
  approx : `int`, default=0 (read-only)
      Level of approximation used for computing exponential functions
  
      * if 0: no approximation
      * if 1: a fast approximated exponential function is used
  
  n_threads : `int`, default=1
      Number of threads used for parallel computation.
  
      * if ``int <= 0``: the number of threads available on
        the CPU
      * otherwise the desired number of threads
  
  Attributes
  ----------
  n_nodes : `int` (read-only)
      Number of components, or dimension of the Hawkes model
  
  data : `list` of `numpy.array` (read-only)
      The events given to the model through `fit` method.
      Note that data given through `incremental_fit` is not stored
class_docstr_tok: ["Hawkes","process","model","exponential","kernels","with","fixed","and","given","decays",".","It","is","modeled","with","least","square","loss",":","..","math",":",":","\\sum_","{","i=1","}","^","{","D","}","\\left","(","\\int_0^T","\\lambda_i","(","t",")","^2","dt","-","2","\\int_0^T","\\lambda_i","(","t",")","dN_i","(","t",")","\\right",")","where",":","math",":","`","\\lambda_i","`","is","the","intensity",":","..","math",":",":","\\forall","i","\\in","[","1","\\dots","D","]",",","\\quad","\\lambda_i","(","t",")","=","\\mu_i","+","\\sum_","{","j=1","}","^D","\\sum_","{","t_k^j","<","t","}","\\phi_","{","ij","}","(","t","-","t_k^j",")","where","*",":","math",":","`","D","`","is","the","number","of","nodes","*",":","math",":","`","\\mu_i","`","are","the","baseline","intensities","*",":","math",":","`","\\phi_","{","ij","}","`","are","the","kernels","*",":","math",":","`","t_k^j","`","are","the","timestamps","of","all","events","of","node",":","math",":","`","j","`","and","with","an","exponential","parametrisation","of","the","kernels","..","math",":",":","\\phi_","{","ij","}","(","t",")","=","\\alpha^","{","ij","}","\\beta^","{","ij","}","\\exp","(","-","\\beta^","{","ij","}","t",")","1_","{","t",">","0","}","In","our","implementation","we","denote",":","*","Integer",":","math",":","`","D","`","by","the","attribute","`","n_nodes","`","*","Matrix",":","math",":","`","B","=","(","\\beta_","{","ij","}",")","_","{","ij","}","\\in","\\mathbb","{","R","}","^","{","D","\\times","D","}","`","by","the","parameter","`","decays","`",".","This","parameter","is","given","to","the","model","Parameters","--","--","--","--","--","decays",":","`","float","`","or","`","numpy.ndarray","`",",","shape=","(","n_nodes",",","n_nodes",")","Either","a","`","float","`","giving","the","decay","of","all","exponential","kernels","or","a","(","n_nodes",",","n_nodes",")","`","numpy.ndarray","`","giving","the","decays","of","the","exponential","kernels","for","all","pairs","of","nodes",".","approx",":","`","int","`",",","default=0","(","read-only",")","Level","of","approximation","used","for","computing","exponential","functions","*","if","0",":","no","approximation","*","if","1",":","a","fast","approximated","exponential","function","is","used","n_threads",":","`","int","`",",","default=1","Number","of","threads","used","for","parallel","computation",".","*","if","``","int","<","=","0","``",":","the","number","of","threads","available","on","the","CPU","*","otherwise","the","desired","number","of","threads","Attributes","--","--","--","--","--","n_nodes",":","`","int","`","(","read-only",")","Number","of","components",",","or","dimension","of","the","Hawkes","model","data",":","`","list","`","of","`","numpy.array","`","(","read-only",")","The","events","given","to","the","model","through","`","fit","`","method",".","Note","that","data","given","through","`","incremental_fit","`","is","not","stored"]
docstr: Incrementally fit model with data by adding one Hawkes realization.
  
  Parameters
  ----------
  events : `list` of `np.ndarray`
      The events of each component of the realization. Namely
      `events[j]` contains a one-dimensional `np.ndarray` of
      the events' timestamps of component j
  
  end_time : `float`, default=None
      End time of the realization.
      If None, it will be set to realization's latest time.
  
  Notes
  -----
  Data is not stored, so this might be useful if the list of all
  realizations does not fit in memory
docstr_tok: ["Incrementally","fit","model","with","data","by","adding","one","Hawkes","realization",".","Parameters","--","--","--","--","--","events",":","`","list","`","of","`","np.ndarray","`","The","events","of","each","component","of","the","realization",".","Namely","`","events","[","j","]","`","contains","a","one-dimensional","`","np.ndarray","`","of","the","events","'","timestamps","of","component","j","end_time",":","`","float","`",",","default=None","End","time","of","the","realization",".","If","None",",","it","will","be","set","to","realization","'s","latest","time",".","Notes","--","--","-","Data","is","not","stored",",","so","this","might","be","useful","if","the","list","of","all","realizations","does","not","fit","in","memory"]
code: def incremental_fit(self, events, end_time=None):
      """Incrementally fit model with data by adding one Hawkes realization.
  
      Parameters
      ----------
      events : `list` of `np.ndarray`
          The events of each component of the realization. Namely
          `events[j]` contains a one-dimensional `np.ndarray` of
          the events' timestamps of component j
  
      end_time : `float`, default=None
          End time of the realization.
          If None, it will be set to realization's latest time.
  
      Notes
      -----
      Data is not stored, so this might be useful if the list of all
      realizations does not fit in memory
      """
      ModelHawkes.incremental_fit(self, events, end_time=end_time)
  
      # self.n_nodes will have correct value once data has been given to model
      decays = self.decays
      if isinstance(decays, (int, float)):
          decays_matrix = (
              np.zeros((self.n_nodes, self.n_nodes)) + decays
          )
          self._model.set_decays(decays_matrix)
  
file_path: tick/tick/hawkes/model/model_hawkes_expkern_leastsq.py
imports: import numpy
  from tick.base_model import LOSS_AND_GRAD
  from tick.hawkes.model.build.hawkes_model import ModelHawkesExpKernLeastSq
  from .base import ModelHawkes
label_desc: Use image node_id 3 for calling the ModelHawkesExpKernLeastSq obj's underlying member method code with example usage: obj.incremental_fit(events, end_time) without return types