ganit_core/eval/functions/statistical/stdev/
mod.rs1use crate::types::{ErrorKind, Value};
2use super::stat_helpers::collect_nums;
3use super::var_s::sample_variance;
4
5pub fn stdev_fn(args: &[Value]) -> Value {
7 if args.is_empty() {
8 return Value::Error(ErrorKind::NA);
9 }
10 let nums = collect_nums(args);
11 match sample_variance(&nums) {
12 Value::Number(v) => {
13 let s = v.sqrt();
14 if !s.is_finite() {
15 Value::Error(ErrorKind::Num)
16 } else {
17 Value::Number(s)
18 }
19 }
20 other => other,
21 }
22}
23
24#[cfg(test)]
25mod tests;