Integrate from 3 StdDevs down instead of starting at 0

This commit is contained in:
Vecna 2024-05-27 19:49:19 -04:00
parent a8a0983f9e
commit df813355c8
1 changed files with 10 additions and 2 deletions

View File

@ -376,11 +376,19 @@ impl Analyzer for NormalAnalyzer {
if mvn.is_ok() {
let mvn = mvn.unwrap();
// Start 3 standard deviations below the mean, based on
// 68-95-99.7 rule, assuming the confidence will be high
// enough that 99.7 is close enough to "the whole
// distribution" to be reasonable
let bip_start = (bridge_ips_mean - (3.0 * bridge_ips_f64.std_dev()).ceil()) as i32;
let pr_start =
(positive_reports_mean - (3.0 * positive_reports_f64.std_dev()).ceil()) as i32;
// Estimate the CDF by integrating the PDF by hand with step
// size 1
let mut cdf = 0.0;
for bip in 0..bridge_ips_today {
for pr in 0..positive_reports_today {
for bip in bip_start..bridge_ips_today as i32 {
for pr in pr_start..positive_reports_today as i32 {
cdf += mvn.pdf(&DVector::from_vec(vec![bip as f64, pr as f64]));
}
}