mirror of
https://github.com/arnaucube/phantom-zone.git
synced 2026-01-11 16:41:29 +01:00
check noise growth in some_work
This commit is contained in:
@@ -1829,7 +1829,7 @@ mod tests {
|
||||
RgswCiphertext, RgswCiphertextEvaluationDomain, SeededRgswCiphertext,
|
||||
SeededRlweCiphertext,
|
||||
},
|
||||
utils::negacyclic_mul,
|
||||
utils::{negacyclic_mul, Stats},
|
||||
};
|
||||
|
||||
use super::*;
|
||||
@@ -2258,41 +2258,6 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
struct Stats<T> {
|
||||
samples: Vec<T>,
|
||||
}
|
||||
|
||||
impl<T: PrimInt + FromPrimitive + Debug> Stats<T>
|
||||
where
|
||||
// T: for<'a> Sum<&'a T>,
|
||||
T: for<'a> std::iter::Sum<&'a T> + std::iter::Sum<T>,
|
||||
{
|
||||
fn mean(&self) -> f64 {
|
||||
self.samples.iter().sum::<T>().to_f64().unwrap() / (self.samples.len() as f64)
|
||||
}
|
||||
|
||||
fn std_dev(&self) -> f64 {
|
||||
let mean = self.mean();
|
||||
|
||||
// diff
|
||||
let diff_sq = self
|
||||
.samples
|
||||
.iter()
|
||||
.map(|v| {
|
||||
let t = v.to_f64().unwrap() - mean;
|
||||
t * t
|
||||
})
|
||||
.into_iter()
|
||||
.sum::<f64>();
|
||||
|
||||
(diff_sq / (self.samples.len() as f64)).sqrt()
|
||||
}
|
||||
|
||||
fn add_more(&mut self, values: &[T]) {
|
||||
self.samples.extend(values.iter());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tester() {
|
||||
// pub(super) const TEST_MP_BOOL_PARAMS: BoolParameters<u64> =
|
||||
|
||||
Reference in New Issue
Block a user