surrealdb-sql 1.1.0

Full type definitions for the SurrealQL query language
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use crate::fnc::util::math::mean::Mean;
use crate::fnc::util::math::variance::variance;
use crate::number::Number;

pub trait Deviation {
	/// Population Standard Deviation
	fn deviation(self, sample: bool) -> f64;
}

impl Deviation for Vec<Number> {
	fn deviation(self, sample: bool) -> f64 {
		deviation(&self, self.mean(), sample)
	}
}

pub(super) fn deviation(v: &[Number], mean: f64, sample: bool) -> f64 {
	variance(v, mean, sample).sqrt()
}