pointprocesses/likelihood/
mod.rs

1//! Utility functions to compute the log-likelihood of the data under the models.
2//! The general form is given by
3//! $$
4//!     \ell(\Theta) = \sum_i \log(\lambda_{t_i}) - \int_0^T \lambda_t dt
5//! $$
6mod hawkes;
7
8pub use hawkes::{hawkes_likelihood,HawkesLikelihood};
9
10use ndarray::prelude::*;
11
12use crate::temporal::{PoissonProcess, DeterministicIntensity};
13
14/// Log-likelihood of the data under the given Poisson model
15/// $$ \ell(\lambda) =
16///    N\ln\lambda - \lambda T
17/// $$
18pub fn poisson_likelihood(
19    times: ArrayView1<f64>,
20    model: &PoissonProcess,
21    tmax: f64) -> f64
22{
23    let n_events = times.len();
24    let lbda = model.intensity(0.);
25    n_events as f64 * lbda.ln() - lbda * tmax
26}
27