surrealdb-core 3.2.0

A scalable, distributed, collaborative, document-graph database, for the realtime web
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use super::median::Median;
use super::midhinge::Midhinge;
use crate::val::Number;
use crate::val::number::Sorted;

pub trait Trimean {
	/// Bowley's Trimean - the Average of the median and the MidHinge
	/// ( 2 * Q_2 + Q_1 + Q_3 ) / 4 == ( Q_2 + ( Q_1 + Q_3 ) ) / 2
	fn trimean(self) -> f64;
}

impl Trimean for Sorted<&Vec<Number>> {
	fn trimean(self) -> f64 {
		(self.midhinge() + self.median()) * 0.5
	}
}