Skip to main content

diffusion_coefficient

Function diffusion_coefficient 

Source
pub fn diffusion_coefficient(msd_data: &[(f64, f64)]) -> f64
Expand description

Estimates the diffusion coefficient from mean-squared displacement (MSD) data.

Performs a linear regression of MSD vs time and returns slope / 2 (the 1-D Einstein relation: MSD = 2*D*t).

Returns 0.0 if there are fewer than 2 data points.