Module HawkesPyLib.inference
Classes
class ExpHawkesProcessInference (rng=Generator(PCG64))
-
Fitting of unvivariate Hawkes processes with single exponentials memory kernel. The Hawkes process with single exponential memory kernel ('expo' kernel), is defined by the conditional intensity function:
\lambda(t) = \mu + \dfrac{\eta}{\theta} \sum_{t_i < t} e^{(-(t - t_i)/\theta)}
Two maximum likelihood based inference methods are currently available:
-
ExpHawkesProcessInference.estimate()
maximizes the log-likelihood given a sample of arrival times. -
ExpHawkesProcessInference.estimate_grid()
maximizes the log-likelihood on a grid of different starting values and returns the best model out of all fitted models (i.e. the model with the highest log-likelihood). A single optimization run may get stuck in a local supoptimal maximum. The grid estimation increases the chance of finding the global maximum but also significantly increases the computational cost.
This class inherets from
UnivariateHawkesProcess
and provides methods for further analysis of the fitted model:- ExpHawkesProcessInference.compensator() computes the compensator and may be used as a starting point for a 'residual' analysis.
- ExpHawkesProcessInference.intensity() evaluates the estimated conditional intensity.
- ExpHawkesProcessInference.kernel_values() returns values for the estimated memory kernel.
- ExpHawkesProcessInference.ic() computes information criteria of the estimated model.
Args
rng
:optional
- numpy random number generator.
For reproducible results use: rng=np.random.default_rng(seed)
Attributes
mu
:float
- The estimated background intensity.
eta
:float
- The estimated branching ratio.
theta
:float
- Estimated decay speed of the single exponential kernel.
timestamps
:np.ndarray
- 1d array of arrival times that were used in the most recent fitting routine.
T
- (float): End time of the estimated process.
logL
:Float
- The log-likelihood value of the fitted process.
Ancestors
Methods
def estimate(self, timestamps: numpy.ndarray, T: float, return_params: bool = False, max_attempts: int = 5, custom_param_vec0: bool = False, **kwargs) ‑> None
-
Estimates process parameters using maximum likelihood estimation.
Args
timestamps
:np.ndarray
- 1d array of arrival times. Must be sorted and only positive timestamps are allowed!
T
:float
- The end time of the Hawkes process.
Must be larger or equal the last arrival time in argument
timestamps
. return_params
:bool
, optional- If True, returns a tuple of fitted parameters in the order: mu, eta, alpha, tau0
max_attempts
:int
, optional- Number of times the maximum likelihood estimation repeats with new starting values if the optimization routine does not exit successfully. Defaults to 5.
custom_param_vec0
:bool
, optional- If custom initial values should be used. Defaults to False.
If True you must supply an addtional variable to **kwargs
called
param_vec0
a 1d numpy array containing the initial starting values: param_vec0 = [mu0 > 0, 0 < eta0 < 1, theta > 0].
Returns
tuple
- (optional) if
return_params=True
returns a tuple of fitted parameters:mu
,eta
,theta
def estimate_grid(self, timestamps: numpy.ndarray, T: float, grid_type: str = 'equidistant', grid_size: int = 20, return_params: bool = False, **kwargs)
-
Estimates the Hawkes process parameters using maximum likelihood estimation. Fits the model multiple times using different initial parameter values. Subsequently the fitted model with the largest log-likelihood value is returned.
The grid applies only to the initial value of eta in the MLE routine, mu0 is set by using the unconditonal mean of the process and theta is chosen randomly.
There are three options for the type of eta0 starting value grid:
-
'random': starting values for eta0 are chosen randomly.
-
'equidistant': starting values for eta0 are equidistant between 0 and 1.
-
'custom': A custom eta0 grid of starting values is supplied to **kwargs argument called
custom-grid
. You must supply an addtional variable 'custom-grid' a 1d numpy array containing a grid of initial starting values with constraint 0 < eta0 < 1.
Args
timestamps
:np.ndarray
- 1d array of arrival times. Must be sorted and only positive timestamps are allowed!
T
:float
- The end time of the Hawkes process.
Must be larger or equal the last arrival time in argument
timestamps
. grid_type
:str
, optional- Type of grid for eta0 starting values, one of: 'random', 'equidistant' or 'custom'. Default to 'equidistant'.
grid_size
:int
, optional- The number of optimizations to run. Defaults to 20.
return_params
:bool
, optional- If True returns a tuple of fitted parameters in the order: mu, eta, theta
Returns
tuple
- (optional) if
return_params=True
returns a tuple of fitted parameters:mu
,eta
,theta
-
def get_params(self) ‑> tuple
-
Returns the fitted model parameters:
Returns
tuple
- Tuple of parameter values that are ordered as follows:
mu
(float),eta
(float),theta
(float) def intensity(self, step_size: float) ‑> numpy.ndarray
-
Evaluates the intensity function \lambda(t) on a grid of equidistant timestamps over the closed interval [0, T] with step size
step_size
.Note
- Additionally to the equidistant time grid the intensity is evaluated at each simulated arrival time.
- If the process end time T is not perfectly divisible by the step size the 'effective' step size deviates slightly from the given one.
Args
step_size
:float
- Step size of the time grid.
Returns
np.ndarray
- 2d array of timestamps (column 0) and corresponding intensity values (column 1)
def compensator(self)
-
Computes the compensator of the process at the set timestamps given the set parameter values. The compensator of a point process is defined as the integral of the conditional intensity: \Lambda(t) = \int_0^t \lambda(u) du
Tip
If the set arrival times are a realization of the Hawkes process specified by the set parameters, the resulting compensator will be a Poisson process with unit intensity (assuming a large enough sample size).
Returns
np.ndarray
- 1d array of timestamps (the compensator)
def kernel_values(self, times: numpy.ndarray) ‑> numpy.ndarray
-
Returns the value of the memory kernel at given time values.
The single exponential memory kernel:
g(t) = \dfrac{\eta}{\theta} e^{(-t/\theta)}
The P-sum exponential memory kernel:
g(t) = \dfrac{\eta}{P} \sum_{k=1}^{P} \dfrac{1}{\theta_k} e^{(-t/\theta_k)}
The approximate power-law memory kernel:
g(t) = \dfrac{\eta}{Z} \bigg[ \sum_{k=0}^{M-1} a_k^{-(1+\alpha)} e^{(-(t - t_i)/a_k)} \bigg]
And the approximate power-law kernel with smooth cutoff :
g(t) = \dfrac{\eta}{Z} \bigg[ \sum_{k=0}^{M-1} a_k^{-(1+\alpha)} e^{(-(t - t_i)/a_k)} - S e^{(-(t - t_i)/a_{-1})} \bigg]
Args
times
:np.ndarray
- 1d array of time values for which to compute the value of the memory kernel.
Returns
np.ndarray
- 1d array containing the values of the memory kernel value at the given time(s).
def compute_logL(self)
-
Computes the log-likelihood function given the process parameters, arrival times and process end time T.
The log-likelihood function of a Hawkes process is given by: logL(t_1,..., t_n) = -\int_0^T \lambda(t) du + \sum_{t=1}^n log(\lambda(t_i))
Returns
float
- The log-likelihood value
def ic(self, type: str) ‑> float
-
Calculates one of the following information criteria given the set parameters and arrival times:
-
'aic': Akaike information criteria
-
'bic': Baysian information criteria
-
'hq': Hannan-Quinn information criteria
Args
type
:str
- Which information criterion to return, must be one of: 'aic', 'bic', 'hq'
Returns
float
- The information criterions value
-
-
class SumExpHawkesProcessInference (P: int, rng=Generator(PCG64))
-
Fitting of unvivariate Hawkes processes with P-sum exponentials memory kernels. A Hawkes process with P-sum exponential memory kernel ('sum-expo' kernel), is defined by the conditional intensity function: \lambda(t) = \mu + \dfrac{\eta}{P} \sum_{t_i < t} \sum_{k=1}^{P} \dfrac{1}{\theta_k} e^{(-(t - t_i)/\theta_k)}
Two maximum likelihood based inference methods are currently available:
-
ExpHawkesProcessInference.estimate()
maximizes the log-likelihood given a sample of arrival times. -
ExpHawkesProcessInference.estimate_grid()
maximizes the log-likelihood on a grid of different starting values and returns the best model out of all fitted models (i.e. the model with the highest log-likelihood). A single optimization run may get stuck in a local supoptimal maximum. The grid estimation increases the chance of finding the global maximum but also significantly increases the computational cost.
This class inherets from
UnivariateHawkesProcess
and provides methods for further analysis of the fitted model:- ExpHawkesProcessInference.compensator() computes the compensator and may be used as a starting point for a 'residual' analysis.
- ExpHawkesProcessInference.intensity() evaluates the estimated conditional intensity.
- ExpHawkesProcessInference.kernel_values() returns values for the estimated memory kernel.
- ExpHawkesProcessInference.ic() computes information criteria of the estimated model.
Args
P
:int
- The number of exponentials that make up the P-sum exponential memory kernel.
rng
:optional
- numpy random generator. For reproducible results use: rng=np.random.default_rng(seed)
Attributes
mu
:float
- The estimated background intensity.
eta
:float
- The estimated branching ratio.
theta_vec
:np.ndarray
, optional- Estimated decay speeds of the P exponential kernels.
timestamps
:np.ndarray
- 1d array of arrival times that were used in the most recent fitting routine.
T
:float
- End time of the Hawkes process.
logL
:Float
- The log-likelihood value of the fitted process.
Ancestors
Methods
def estimate(self, timestamps: numpy.ndarray, T: float, return_params: bool = False, max_attempts: int = 5, custom_param_vec0: bool = False, **kwargs)
-
Estimates the Hawkes process parameters using maximum likelihood estimation.
Args
timestamps
:np.ndarray
- 1d array of arrival times. Must be sorted and only positive timestamps are allowed!
T
:float
- The end time of the Hawkes process.
Must be larger or equal the last arrival time in argument
timestamps
. return_params
:bool
, optional- If True, returns a tuple of fitted parameters in the order: mu, eta, alpha, tau0
max_attempts
:int
, optional- Number of times the maximum likelihood estimation repeats with new starting values if the optimization routine does not exit successfully. Defaults to 5.
custom_param_vec0
:bool
, optional- If custom initial values should be used. Defaults to False.
If true you must supply an addtional variable to **kwargs
called
param_vec0
a 1d numpy array containing the initial starting values: param_vec0 = [mu0 > 0, 0 < eta0 <1, theta1_0 > 0, …, theta1_0].
Returns
tuple
- (optional) if
return_params=True
returns a tuple of fitted parameters:mu
,eta
,theta_vec
def estimate_grid(self, timestamps: numpy.ndarray, T: float, grid_type: str = 'equidistant', grid_size: int = 20, return_params: bool = False, rng=Generator(PCG64), **kwargs)
-
Estimates the Hawkes process parameters using maximum likelihood estimation. Fits the model multiple times using different initial parameter values. Subsequently the fitted model with the largest log-likelihood value is returned.
The grid applies only to the initial value of eta in the MLE routine, mu0 is set by using the unconditonal mean of the process and theta is chosen randomly.
There are three options for the type of eta0 starting value grid:
-
'random': starting values for eta0 are chosen randomly.
-
'equidistant': starting values for eta0 are equidistant between 0 and 1.
-
'custom': A custom eta0 grid of starting values is supplied to **kwargs argument called 'custom-grid'. You must supply an addtional variable 'custom-grid' a 1d numpy array containing a grid of initial starting values with constraint 0 < eta0 < 1.
Args
timestamps
:np.ndarray
- 1d array of arrival times. Must be sorted and only positive timestamps are allowed!
T
:float
- The end time of the Hawkes process.
Must be larger or equal the last arrival time in argument
timestamps
. grid_type
:str
, optional- Type of grid for eta0 starting values, one of: 'random', 'equidistant' or 'custom'. Default to 'equidistant'
grid_size
:int
, optional- The number of optimizations to run. Defaults to 20.
return_params
:bool
, optional- If True returns a tuple of fitted parameters in the order: mu, eta, alpha, tau0
Returns
tuple
- (optional) if
return_params=True
returns a tuple of fitted parameters:mu
,eta
,theta_vec
-
def get_params(self) ‑> tuple
-
Returns the fitted model parameters:
Returns
tuple
- Tuple of parameter values with order and types:
mu
(float),eta
(float),theta_vec
(np.ndarray) def intensity(self, step_size: float) ‑> numpy.ndarray
-
Evaluates the intensity function \lambda(t) on a grid of equidistant timestamps over the closed interval [0, T] with step size
step_size
.Note
- Additionally to the equidistant time grid the intensity is evaluated at each simulated arrival time.
- If the process end time T is not perfectly divisible by the step size the 'effective' step size deviates slightly from the given one.
Args
step_size
:float
- Step size of the time grid.
Returns
np.ndarray
- 2d array of timestamps (column 0) and corresponding intensity values (column 1)
def compensator(self)
-
Computes the compensator of the process at the set timestamps given the set parameter values. The compensator of a point process is defined as the integral of the conditional intensity: \Lambda(t) = \int_0^t \lambda(u) du
Tip
If the set arrival times are a realization of the Hawkes process specified by the set parameters, the resulting compensator will be a Poisson process with unit intensity (assuming a large enough sample size).
Returns
np.ndarray
- 1d array of timestamps (the compensator)
def kernel_values(self, times: numpy.ndarray) ‑> numpy.ndarray
-
Returns the value of the memory kernel at given time values.
The single exponential memory kernel:
g(t) = \dfrac{\eta}{\theta} e^{(-t/\theta)}
The P-sum exponential memory kernel:
g(t) = \dfrac{\eta}{P} \sum_{k=1}^{P} \dfrac{1}{\theta_k} e^{(-t/\theta_k)}
The approximate power-law memory kernel:
g(t) = \dfrac{\eta}{Z} \bigg[ \sum_{k=0}^{M-1} a_k^{-(1+\alpha)} e^{(-(t - t_i)/a_k)} \bigg]
And the approximate power-law kernel with smooth cutoff :
g(t) = \dfrac{\eta}{Z} \bigg[ \sum_{k=0}^{M-1} a_k^{-(1+\alpha)} e^{(-(t - t_i)/a_k)} - S e^{(-(t - t_i)/a_{-1})} \bigg]
Args
times
:np.ndarray
- 1d array of time values for which to compute the value of the memory kernel.
Returns
np.ndarray
- 1d array containing the values of the memory kernel value at the given time(s).
def compute_logL(self)
-
Computes the log-likelihood function given the process parameters, arrival times and process end time T.
The log-likelihood function of a Hawkes process is given by: logL(t_1,..., t_n) = -\int_0^T \lambda(t) du + \sum_{t=1}^n log(\lambda(t_i))
Returns
float
- The log-likelihood value
def ic(self, type: str) ‑> float
-
Calculates one of the following information criteria given the set parameters and arrival times:
-
'aic': Akaike information criteria
-
'bic': Baysian information criteria
-
'hq': Hannan-Quinn information criteria
Args
type
:str
- Which information criterion to return, must be one of: 'aic', 'bic', 'hq'
Returns
float
- The information criterions value
-
-
class ApproxPowerlawHawkesProcessInference (kernel: str, m: float, M: int, rng=Generator(PCG64))
-
Fitting of unvivariate Hawkes processes with approximate power-law memory kernel. The Hawkes process with approximate power-law kernel ('powlaw'
kernel
), is defined by the conditional intensity fnuction: \lambda(t) = \mu + \sum_{t_i < t} \dfrac{\eta}{Z} \bigg[ \sum_{k=0}^{M-1} a_k^{-(1+\alpha)} e^{(-(t - t_i)/a_k)} \bigg],where \mu (
mu
) is the constant background intensity, \eta (eta
) is the branching ratio, \alpha (alpha
) is the power-law tail exponent and \tau_0 a scale parameter controlling the decay timescale.The Hawkes process with approximate power-law kernel with smooth cutoff ('powlaw-cutoff'
kernel
), defined by the conditional intenstiy fnuction: \lambda(t) = \mu + \sum_{t_i < t} \dfrac{\eta}{Z} \bigg[ \sum_{k=0}^{M-1} a_k^{-(1+\alpha)} e^{(-(t - t_i)/a_k)} - S e^{(-(t - t_i)/a_{-1})} \bigg],where \mu (
mu
) is the constant background intensity, \eta (eta
) is the branching ratio, \alpha (alpha
) is the power-law tail exponent and \tau_0 a scale parameter controlling the decay timescale and the location of the smooth cutoff point (i.e. the time duration after each jump at which the intensity reaches a maximum).The true power-law is approximtated by a sum of M exponential functions with power-law weights a_k = \tau_0 m^k. M is the number of exponentials used for the approximation and m is a scale parameter. The power-law approximation holds for times up to m^{M-1} after which the memory kernel decays exponentially. S and Z are scaling factors that ensure that the memory kernel integrates to \eta and that the kernel value at time zero is zero (for the smooth cutoff version). S and Z are computed automatically.
Two maximum likelihood based inference methods are currently available:
-
ExpHawkesProcessInference.estimate()
maximizes the log-likelihood given a sample of arrival times. -
ExpHawkesProcessInference.estimate_grid()
maximizes the log-likelihood on a grid of different starting values and returns the best model out of all fitted models (i.e. the model with the highest log-likelihood). A single optimization run may get stuck in a local supoptimal maximum. The grid estimation increases the chance of finding the global maximum but also significantly increases the computational cost.
This class inherets from
UnivariateHawkesProcess
and provides methods for further analysis of the fitted model:- ExpHawkesProcessInference.compensator() computes the compensator and may be used as a starting point for a 'residual' analysis.
- ExpHawkesProcessInference.intensity() evaluates the estimated conditional intensity.
- ExpHawkesProcessInference.kernel_values() returns values for the estimated memory kernel.
- ExpHawkesProcessInference.ic() computes information criteria of the estimated model.
Args
kernel
:str
- Must be one of: 'powlaw', 'powlaw-cutoff'. Specifies the shape of the approximate power-law kernel
m
:float
- Scale parameter that that specifies the approximation of the true power-law. Must be positive.
M
:int
- The number of weighted exponential kernels that specifies the approximation of the true power-law. Must be positive.
rng
:optional
- numpy numba generator. For reproducible results use: np.random.default_rng(seed)
Attributes
mu
:float
- The estimated background intensity.
eta
:float
- The estimated branching ratio.
alpha
:float
- Estimated tail exponent of the power-law decay.
tau0
:float
- Estimated timescale parameter.
timestamps
:np.ndarray
- 1d array of arrival times that were used in the most recent fitting routine.
T
- (float): End time of the process.
logL
:Float
- The log-likelihood value of the fitted process
Ancestors
Methods
def estimate(self, timestamps: numpy.ndarray, T: float, return_params: bool = False, max_attempts: int = 5, custom_param_vec0: bool = False, **kwargs) ‑> None
-
Estimates the Hawkes process parameters using maximum likelihood estimation.
Args
timestamps
:np.ndarray
- 1d array of arrival times. Must be sorted and only positive timestamps are allowed!
T
:float
- The end time of the Hawkes process.
Must be larger or equal the last arrival time in argument
timestamps
. return_params
:bool
, optional- If True returns a tuple of fitted parameters in the order: mu, eta, alpha, tau0
max_attempts
:int
, optional- Number of times the maximum likelihood estimation repeats with new starting values if the optimization routine does not exit successfully. Defaults to 5.
custom_param_vec0
:bool
, optional- If custom initial values should be used. Defaults to False.
If true you must supply an addtional variable to **kwargs called
param_vec0
a 1d numpy array containing the initial starting values: param_vec0 = [mu0 > 0, 0 < eta0 <1, alpha0 > 0, tau0_0].
Returns
tuple
- (optional) if
return_params=True
returns tuple of fitted parameters:mu
,eta
,alpha
,tau0
def estimate_grid(self, timestamps: numpy.ndarray, T: float, grid_type: str = 'equidistant', grid_size: int = 20, return_params: bool = False, rng=Generator(PCG64), **kwargs) ‑> None
-
Estimates the Hawkes process parameters using maximum likelihood estimation. Fits the model multiple times using different initial parameter values. Subsequently the fitted model with the largest log-likelihood value is returned.
The grid applies only to the initial value of eta in the MLE routine, mu0 is set by using the unconditonal mean of the process and theta is chosen randomly.
There are three options for the type of eta0 starting value grid:
-
'random': starting values for eta0 are chosen randomly.
-
'equidistant': starting values for eta0 are equidistant between 0 and 1.
-
'custom': A custom eta0 grid of starting values is supplied to **kwargs argument called
custom-grid
. You must supply an addtional variable 'custom-grid' a 1d numpy array containing a grid of initial starting values with constraint 0 < eta0 < 1.
Args
timestamps
:np.ndarray
- 1d array of arrival times. Must be sorted and only positive timestamps are allowed!
T
:float
- The end time of the Hawkes process.
Must be larger or equal the last arrival time in argument
timestamps
. grid_type
:str
, optional- Type of grid for eta0 starting values, one of: 'random', 'equidistant' or 'custom'. Default to 'equidistant'
grid_size
:int
, optional- The number of optimizations to run. Defaults to 20.
return_params
:bool
, optional- If True returns a tuple of fitted parameters in the order: mu, eta, alpha, tau0
Returns
tuple
- (optional) if
return_params=True
returns tuple of fitted parameters:mu
,eta
,alpha
,tau0
-
def get_params(self) ‑> tuple
-
Returns the fitted model parameters:
Returns
tuple
- Tuple of parameter with order and types:
mu
(float),eta
(float),alpha
(float),tau0
(float),m
(float),M
(int) def intensity(self, step_size: float) ‑> numpy.ndarray
-
Evaluates the intensity function \lambda(t) on a grid of equidistant timestamps over the closed interval [0, T] with step size
step_size
.Note
- Additionally to the equidistant time grid the intensity is evaluated at each simulated arrival time.
- If the process end time T is not perfectly divisible by the step size the 'effective' step size deviates slightly from the given one.
Args
step_size
:float
- Step size of the time grid.
Returns
np.ndarray
- 2d array of timestamps (column 0) and corresponding intensity values (column 1)
def compensator(self)
-
Computes the compensator of the process at the set timestamps given the set parameter values. The compensator of a point process is defined as the integral of the conditional intensity: \Lambda(t) = \int_0^t \lambda(u) du
Tip
If the set arrival times are a realization of the Hawkes process specified by the set parameters, the resulting compensator will be a Poisson process with unit intensity (assuming a large enough sample size).
Returns
np.ndarray
- 1d array of timestamps (the compensator)
def kernel_values(self, times: numpy.ndarray) ‑> numpy.ndarray
-
Returns the value of the memory kernel at given time values.
The single exponential memory kernel:
g(t) = \dfrac{\eta}{\theta} e^{(-t/\theta)}
The P-sum exponential memory kernel:
g(t) = \dfrac{\eta}{P} \sum_{k=1}^{P} \dfrac{1}{\theta_k} e^{(-t/\theta_k)}
The approximate power-law memory kernel:
g(t) = \dfrac{\eta}{Z} \bigg[ \sum_{k=0}^{M-1} a_k^{-(1+\alpha)} e^{(-(t - t_i)/a_k)} \bigg]
And the approximate power-law kernel with smooth cutoff :
g(t) = \dfrac{\eta}{Z} \bigg[ \sum_{k=0}^{M-1} a_k^{-(1+\alpha)} e^{(-(t - t_i)/a_k)} - S e^{(-(t - t_i)/a_{-1})} \bigg]
Args
times
:np.ndarray
- 1d array of time values for which to compute the value of the memory kernel.
Returns
np.ndarray
- 1d array containing the values of the memory kernel value at the given time(s).
def compute_logL(self)
-
Computes the log-likelihood function given the process parameters, arrival times and process end time T.
The log-likelihood function of a Hawkes process is given by: logL(t_1,..., t_n) = -\int_0^T \lambda(t) du + \sum_{t=1}^n log(\lambda(t_i))
Returns
float
- The log-likelihood value
def ic(self, type: str) ‑> float
-
Calculates one of the following information criteria given the set parameters and arrival times:
-
'aic': Akaike information criteria
-
'bic': Baysian information criteria
-
'hq': Hannan-Quinn information criteria
Args
type
:str
- Which information criterion to return, must be one of: 'aic', 'bic', 'hq'
Returns
float
- The information criterions value
-
-
class PoissonProcessInference
-
Class for fitting of a homogenous Poisson process with constant rate parameter
mu
. The Poisson process is fitted given arrival times in the half open intervall (0, T]. In contrast to Hawkes processes, the intensity function \lambda(t) , is constant and does not depend on t : \lambda(t) = \mu, \; \forall tThe class may be used to compare the more complicated Hawkes process model fits with a basic 'trivial' model of random arrival times.
Note
Maximum likelihood inference of homogenous Poisson processes is trivial. Simply calculate the number of event arrivales per unit time in order to estimate the constant intensity rate parameter of the process.
Methods
def estimate(self, timestamps: numpy.ndarray, T: float, return_result: bool = False) ‑> None
-
Estimate the constant intensity rate parameter of the homogenous Poisson process.
Args
timestamps
:np.ndarray
- 1d array of arrival times. Must be sorted and only positive timestamps are allowed!
T
:float
- The end time of the Hawkes process.
Must be larger or equal the last arrival time in argument
timestamps
. return_result
:bool
, optional- Should result be returned?. Defaults to False.
Returns
tuple
- If return_result=True returns a tuple: mu, logL
def compensator(self) ‑> numpy.ndarray
-
Computes the compensator of the estimated Poisson process
Returns
np.ndarray
- 1d array of compensator timestamps.
def intensity(self, step_size: float) ‑> numpy.ndarray
-
Evaluates the intensity function \lambda(t) on a grid of equidistant timestamps over the closed interval [0, T] with step size
step_size
. In the case of the homogenous Poisson process this is trivial (i.e. the constant estimated ratemu
).Args
step_size
:float
- Step size of the time grid.
Returns
np.ndarray
- 2d array of timestamps (column 0) and corresponding intensity values (column 1)