pointprocesses/temporal/
traits.rs

1use rayon::prelude::*;
2use ndarray::prelude::*;
3
4/// Result type for temporal processes.
5/// Event timestamps and values of the intensity
6pub struct TimeProcessResult {
7    pub timestamps: Array1<f64>,
8    pub intensities: Array1<f64>
9}
10
11
12/// Time-dependent point process model.
13pub trait TemporalProcess {
14    /// Sample a sequence of events of the process.
15    /// Returns: event timestamps and intensity process.
16    fn sample(&self, tmax: f64) -> TimeProcessResult;
17
18    /// Batch-sample sequences from the model.
19    fn batch_sample(&self, tmax: f64, num_batch: usize) -> Vec<TimeProcessResult>
20    where Self: std::marker::Sync
21    {
22        let range = 0..num_batch;
23        range.into_par_iter().map(|_| {
24            self.sample(tmax)
25        }).collect()
26    }
27}
28
29use std::fmt;
30impl fmt::Debug for TimeProcessResult {
31    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result
32    {
33        f.debug_struct("ProcessTraj")
34            .field("timestamps", &self.timestamps)
35            .field("intensities", &self.intensities)
36            .finish()
37    }
38}
39
40/// Indicates the point process has a deterministic intensity process.
41pub trait DeterministicIntensity {
42    fn intensity(&self, t: f64) -> f64;
43}
44
45/// Indicates the process has a stochastic intensity process;
46pub trait StochasticIntensity {}