pub fn trimmean(list: &[f64], percentage: f64) -> Result<f64, String> {
if list.is_empty() {
return Err("Cannot calculate the trimmed mean of an empty list!".to_string());
}
let ratio: f64 = percentage / 200.0;
let mut temp = list.to_vec();
temp.sort_by(|a,b| a.partial_cmp(b).unwrap());
let trim_count: usize = (temp.len() as f64 * ratio) as usize;
let trimmed = &temp[trim_count..temp.len() - trim_count];
let mut total: f64 = 0.0;
for value in trimmed {
total += *value;
}
Ok(total / trimmed.len() as f64)
}