MCPcopy Create free account
hub / github.com/ciphermodelabs/ciphercore / chi_statistics

Function chi_statistics

ciphercore-base/src/random.rs:363–369  ·  view source on GitHub ↗

Computes chi squared statistics

(counters: &[u64], expected_count_per_element: u64)

Source from the content-addressed store, hash-verified

361
362// Computes chi squared statistics
363pub fn chi_statistics(counters: &[u64], expected_count_per_element: u64) -> f64 {
364 let mut chi_statistics = 0_f64;
365 for c in counters {
366 chi_statistics += (*c as f64 - expected_count_per_element as f64).powi(2);
367 }
368 chi_statistics / expected_count_per_element as f64
369}
370
371#[cfg(test)]
372mod tests {

Calls

no outgoing calls

Tested by 5