use crate::sphere5d::NeuronPoint;
pub fn centroid(points: &[NeuronPoint]) -> [f32; 5] {
let mut c = [0.0f32; 5];
if points.is_empty() {
return c;
}
for p in points {
for (i, v) in p.position.iter().enumerate() {
c[i] += *v;
}
}
let scale = 1.0 / points.len() as f32;
for v in &mut c {
*v *= scale;
}
c
}
pub fn mean_radius(points: &[NeuronPoint], center: [f32; 5]) -> f32 {
if points.is_empty() {
return 0.0;
}
let mut acc = 0.0f32;
for p in points {
let mut d2 = 0.0f32;
for (i, pos_v) in p.position.iter().enumerate() {
let d = *pos_v - center[i];
d2 += d * d;
}
acc += crate::math::sqrtf(d2);
}
acc / points.len() as f32
}