Skip to content

msangnier/kernelhawkes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

kernelhawkes

kernelhawkes is a Python library for nonparametric estimation of nonlinear multivariate Hawkes processes, where the interaction functions are assumed to lie in a reproducing kernel Hilbert space (RKHS).

Example

import numpy as np
import matplotlib.pyplot as plt
from kernelhawkes import HawkesProcess, MultivariateKernelHawkes, plot_kernels

# Simulation
fun_diag1 = lambda x: (8*x**2-1)*(x <= 1/2) + np.exp(-2.5*(x-1/2))*(x > 1/2)
fun_diag2 = lambda x: (8*x**2-1)*(x <= 1/2) + np.exp(-(x-1/2))*(x > 1/2)
hawkes_kernels = [
    [fun_diag1, lambda x: np.exp(-10*(x-1)**2), lambda x: -0.6*np.exp(-3*x**2) - 0.4*np.exp(-3*(x-1)**2)],
    [lambda x: 2**(-5*x), fun_diag2, lambda x: -np.exp(-2*(x-3)**2)],
    [lambda x: -np.exp(-5*(x-2)**2), lambda x: (1+np.cos(np.pi*x)) * np.exp(-x)/2, fun_diag1]
]

hp = HawkesProcess(mu=0.05 * np.ones(len(hawkes_kernels)), kernel=hawkes_kernels)
times = hp.simulate(size=200)

# Estimation
multi_rkhs = MultivariateKernelHawkes(link_param=100, support=5, gamma=1e0, reg=1e0)
multi_rkhs.fit(times)
print("Neg-log-lik RKHS model:", multi_rkhs.negloglik(multi_rkhs.param)[0])

# Plot
plot_kernels(dict(true=hp, RKHS=multi_rkhs))
plt.show()

Dependencies

kernelhawkes needs Python >= 3, setuptools, Numpy and Scipy.

Installation

To install kernelhawkes from pip, type:

pip install https://github.com/msangnier/kernelhawkes/archive/master.zip

Authors

Maxime Sangnier

References

  • Nonparametric estimation of Hawkes processes with RKHSs (2025), A. Bonnet and M. Sangnier. AISTATS.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages