1 2 3 4 5 6 7 8 9 10 11 12
use num::Float; /// Calculates the gaussian distance between two lists of floats. pub fn gaussian<N>(q: &[N], c: &[N]) -> N where N: Float { let sum = q .iter() .zip(c) .map(|(qi, ci)| (*qi - *ci).powi(2)) .fold(N::zero(), |acc, x| acc + x); sum.sqrt() }