pub fn compute_stats(points: &[GmpePoint]) -> StatsExpand description
Compute summary statistics (mean, standard deviation, minimum, maximum, and median)
for a list of GmpePoint values.
This function processes the value field from a slice of GmpePoint instances,
computing key statistical measures.
Most operations are parallelized using Rayon where possible (e.g., sum, variance, min, max)
to improve performance on larger datasets.
§Arguments
points- A slice ofGmpePointinstances to analyze.
§Returns
A Stats struct containing:
mean— the arithmetic meanstd_dev— the sample standard deviationmin— the minimum valuemax— the maximum valuemedian— the median value (sorted centrally)
§Example
use ground_motion_lib::gmm::GmpePoint;
use ground_motion_lib::vectorized::{compute_stats, Stats};
let points = vec![
GmpePoint::new_pga(147.1, 50.1, 1.1),
GmpePoint::new_pga(147.2, 50.2, 1.2),
GmpePoint::new_pga(147.3, 50.3, 1.3),
];
let stats = compute_stats(&points);
println!("Mean: {}", stats.mean);
println!("Min: {}", stats.min);
println!("Max: {}", stats.max);
println!("Median: {}", stats.median);
println!("Std Dev: {}", stats.std_dev);§Parallelism
- Sum, variance, min, and max calculations use
Rayon’s parallel iterators. - Median is computed single-threaded via an in-place sort since sorting isn’t parallelized here.
§Panics
This function will panic if called with an empty slice.