Function std_err

Source
pub fn std_err<T>(data: &[T]) -> Option<f64>
where T: ToPrimitive + Debug,
Expand description

Calculate the standard error of a dataset

The standard error quantifies the uncertainty in the sample mean as an estimate of the population mean.

§Arguments

  • data - A slice of numeric values implementing ToPrimitive

§Returns

  • Some(f64) - The standard error if the input slice is non-empty
  • None - If the input slice is empty

§Examples

use rs_stats::prob::std_err;

// Calculate standard error for a dataset
let data = [1.0, 2.0, 3.0, 4.0, 5.0];
let se = std_err(&data).unwrap();
assert!((se - 0.632455532).abs() < 1e-9);

// Handle empty input
let empty_data: &[f64] = &[];
assert!(std_err(empty_data).is_none());