tick.hawkes.
HawkesConditionalLaw
(delta_lag=0.1, min_lag=0.0001, max_lag=40, n_quad=50, max_support=40, min_support=0.0001, quad_method='gauss', marked_components=None, delayed_component=None, delay=1e-05, model=None, n_threads=1, claw_method='lin')[source]¶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:
where
\(D\) is the number of nodes
\(\mu_i\) are the baseline intensities
\(\phi_{ij}\) are the kernels
\(v_j\) are the marks (considered iid) of the process \(N_j\)
\(f_{ij}\) the mark functions supposed to be piece-wise constant on intervals \(I^j(l)\)
The estimation is made from empirical computations of
For all the possible values of \(i\), \(i\) and \(l\). The \(lag\) is sampled on a uniform grid defined by \(\delta\): \(lag = n * \delta\).
Estimation can be performed using several realizations.
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 \(\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
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 CPUotherwise the desired number of threads
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 theset_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 theset_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.
__init__
(delta_lag=0.1, min_lag=0.0001, max_lag=40, n_quad=50, max_support=40, min_support=0.0001, quad_method='gauss', marked_components=None, delayed_component=None, delay=1e-05, model=None, n_threads=1, claw_method='lin')[source]¶Initialize self. See help(type(self)) for accurate signature.
fit
(events: list, T=None)[source]¶Fit the model according to the given training data.
events : list
of list
of np.ndarray
List of Hawkes processes realizations. Each realization of the Hawkes process is a list of n_node for each component of the Hawkes. Namely
events[i][j]
contains a one-dimensionalnumpy.array
of the events’ timestamps of component j of realization i. If only one realization is given, it will be wrapped into a list
T : double
, default=None
The duration (in physical time) of the realization. If it is None then T is considered to be the time of the last event (of any component).
output : HawkesConditionalLaw
The current instance of the Learner
get_kernel_norms
()[source]¶Computes kernel norms. This makes our learner compliant with
tick.plot.plot_hawkes_kernel_norms
API
norms : np.ndarray
, shape=(n_nodes, n_nodes)
2d array in which each entry i, j corresponds to the norm of kernel i, j
get_kernel_supports
()[source]¶Computes kernel support. This makes our learner compliant with
tick.plot.plot_hawkes_kernels
API
output : np.ndarray
, shape=(n_nodes, n_nodes)
2d array in which each entry i, j corresponds to the support of kernel i, j
get_kernel_values
(i, j, abscissa_array)[source]¶Computes value of the specified kernel on given time values. This
makes our learner compliant with tick.plot.plot_hawkes_kernels
API
i : int
First index of the kernel
j : int
Second index of the kernel
abscissa_array : np.ndarray
, shape=(n_points, )
1d array containing all the times at which this kernel will computes it value
output : np.ndarray
, shape=(n_points, )
1d array containing the values of the specified kernels at the given times.
incremental_fit
(realization, T=None, compute=True)[source]¶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
).
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 componentlist 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 callcompute
method afterwards. This is useful to add multiple realizations and compute only once all conditional laws have been updated.
set_model
(symmetries1d=[], symmetries2d=[], delayed_component=None)[source]¶Set the model to be used.
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 theset_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 theset_model
method.
delayed_component : list of int
, shape=(N, ), 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)
If no model is specified then default values for these fields are used :
Notes
We set the symmetries, the kernel names and delayed components for first realization only