pub trait PointProcess: Send + Sync {
// Required method
fn simulate_with_step(&self, num_step: usize) -> XResult<Pair>;
// Provided methods
fn simulate_with_duration(&self, duration: f64) -> XResult<Pair>
where Self: Sized { ... }
fn mean(&self, duration: f64, particles: usize) -> XResult<f64>
where Self: Sized + Clone + PointTrajectoryTrait { ... }
fn msd(&self, duration: f64, particles: usize) -> XResult<f64>
where Self: Sized + Clone + PointTrajectoryTrait { ... }
fn raw_moment(
&self,
duration: f64,
order: i32,
particles: usize,
) -> XResult<f64>
where Self: Sized + Clone + PointTrajectoryTrait { ... }
fn central_moment(
&self,
duration: f64,
order: i32,
particles: usize,
) -> XResult<f64>
where Self: Sized + Clone + PointTrajectoryTrait { ... }
fn fpt(&self, domain: (f64, f64), max_duration: f64) -> XResult<Option<f64>>
where Self: Sized { ... }
fn occupation_time(&self, domain: (f64, f64), duration: f64) -> XResult<f64>
where Self: Sized { ... }
}
Expand description
Point process trait
Required Methods§
Provided Methods§
Sourcefn simulate_with_duration(&self, duration: f64) -> XResult<Pair>where
Self: Sized,
fn simulate_with_duration(&self, duration: f64) -> XResult<Pair>where
Self: Sized,
Simulate the point process with given duration
§Arguments
duration
- The duration of the simulation.
Examples found in repository?
examples/ctrw.rs (line 18)
3fn main() {
4 println!("===== Example of CTRW Simulation =====");
5
6 // Create CTRW instance
7 // Parameters: alpha (jump index), beta (waiting time index), start_position (starting position)
8 // alpha=0.8 represents a heavy-tailed jump distribution, beta=0.7 represents a long-tailed waiting time distribution
9 let ctrw = CTRW::new(0.8, 0.7, 0.0).unwrap();
10
11 // Time settings
12 let t_max = 10.0; // Maximum time
13 let dt = 0.1; // Time step
14
15 // Generate CTRW trajectory
16 // Here we call the simulate method provided by the ContinuousProcess trait
17 // Note: The CTRW implementation does not actually use the time_step parameter
18 let (times, positions) = ctrw.simulate_with_duration(t_max).unwrap();
19
20 // Print some data points
21 println!("Time\tPosition");
22 for i in (0..times.len()).step_by(100) {
23 if i < times.len() {
24 println!("{:.2}\t{:.6}", times[i], positions[i]);
25 }
26 }
27
28 let traj = ctrw.duration(t_max).unwrap();
29
30 // Visualize trajectory
31 let config = PlotConfigBuilder::default()
32 .show_grid(false)
33 .time_step(dt)
34 .output_path("tmp/ctrw.svg")
35 .caption("CTRW Trajectory")
36 .x_label("t")
37 .y_label("X(t)")
38 .legend("ctrw")
39 .size((800, 600))
40 .backend(PlotterBackend::SVG)
41 .build()
42 .unwrap();
43
44 traj.plot(&config).unwrap();
45 println!("Trajectory image saved to tmp/ctrw.svg");
46}
Sourcefn mean(&self, duration: f64, particles: usize) -> XResult<f64>
fn mean(&self, duration: f64, particles: usize) -> XResult<f64>
Get the mean of the point process
§Arguments
duration
- The duration of the simulation.particles
- The number of particles.
Sourcefn msd(&self, duration: f64, particles: usize) -> XResult<f64>
fn msd(&self, duration: f64, particles: usize) -> XResult<f64>
Get the mean square displacement of the point process
§Arguments
duration
- The duration of the simulation.particles
- The number of particles.
Sourcefn raw_moment(
&self,
duration: f64,
order: i32,
particles: usize,
) -> XResult<f64>
fn raw_moment( &self, duration: f64, order: i32, particles: usize, ) -> XResult<f64>
Get the raw moment of the point process
§Arguments
duration
- The duration of the simulation.order
- The order of the moment.particles
- The number of particles.
Sourcefn central_moment(
&self,
duration: f64,
order: i32,
particles: usize,
) -> XResult<f64>
fn central_moment( &self, duration: f64, order: i32, particles: usize, ) -> XResult<f64>
Get the central moment of the point process
§Arguments
duration
- The duration of the simulation.order
- The order of the moment.particles
- The number of particles.
Sourcefn fpt(&self, domain: (f64, f64), max_duration: f64) -> XResult<Option<f64>>where
Self: Sized,
fn fpt(&self, domain: (f64, f64), max_duration: f64) -> XResult<Option<f64>>where
Self: Sized,
Get the first passage time of the point process
§Arguments
domain
- The domain which the first passage time is interested in.max_duration
- The maximum duration of the simulation. If the process does not exit the domain before the maximum duration, the function returns None.