MATLAB Examples

# HAWKESDEMO: Simulate and visualize a Hawkes process

(one of constant-unconditional-intensity, first-order, exponential-decay type)

## Univariate process 1

Self-damping: alpha < 0

par1.mu = 0.5; par1.alpha = -0.1; par1.beta = 1; 

## Univariate process 2

Self-exciting: alpha > 0

par2.mu = 0.5; par2.alpha = 0.1; par2.beta = 1; 

## Simulated histories of univariate processes

t = 10; 
h1 = simhawkes1(t,par1); h2 = simhawkes1(t,par2); 

## Intensity-and-event-occurrence plots

showhawkesm(1,t,h1,par1) suptitle(['Univariate Hawkes process, ' ... '\it\lambda(t) = \mu + \Sigma_{\tau_{i}<t} ' ... '\alpha exp\rm[\it-\beta(t-\tau_{i})\rm]']) 
showhawkesm(1,t,h2,par2) suptitle(['Univariate Hawkes process, ' ... '\it\lambda(t) = \mu + \Sigma_{\tau_{i}<t} ' ... '\alpha exp\rm[\it-\beta(t-\tau_{i})\rm]']) 

## Simulated history of a bivariate process

Alas, a multivariate simulator is not yet available. (Can you find a clear recipe? Please send me the reference). We put together two previously generated univariate histories, creating a path of a 'mutually independent' bivariate process.

H = {cell2mat(h1) cell2mat(h2)}; 

## Bivariate process

.. but plot intensities for a 'mutually dependent' one, to check that inthawkesm and showhawkesm routines work correctly. Note that one-way dependence is engineered: series-1 events affect series-2 intensity, but not vice versa.

par.mu = [par1.mu par2.mu]; par.alpha = [par1.alpha 0.0; ... 0.5 par2.alpha]; par.beta = [par1.beta 0.5; ... 0.5 par2.beta]; 

## Intensity-and-event-occurrence plots

showhawkesm(1:2,t,H,par) suptitle(['Multivariate Hawkes process, ' ... '\it\lambda_{i}(t) = \mu_{i} + \Sigma_{j} ' ... '\Sigma_{\tau_{ji}<t} \alpha_{ij}\rm ' ... '\itexp\rm[\it-\beta_{ij}(t-\tau_{ji})\rm]']) 

Example: none (Oh, the FEX code metrics..)