use std::io; // bring flush() into scope with `use std::io::Write`
use std::io::prelude::*; // Bring `std::io::BufRead` in scope
-use statrs::distribution::{Exp, ContinuousCDF}; // Continuous needed for pdf
+use statrs::distribution::{Exp, LogNormal, ContinuousCDF}; // Continuous needed for pdf
// use statrs::statistics::Distribution;
+// use statrs::prec;
const DEBUG: bool = false;
}
+fn lognormal(n: i32) -> Vec<f64> {
+ const NAME: &str = "Lognormal"; // mean of normal distribution (N)
+ const MEAN: f64 = 0.0; // is unessential thanks to
+ const STD: f64 = 1.0; // normalization, and std of N
+ let dist = LogNormal::new(MEAN, STD).unwrap();
+ let mut prio: Vec<f64> = Vec::new();
+ if DEBUG { eprint!("{}: ", NAME) }
+ for i in 1..n + 1 {
+ let f = i as f64 / (n as f64 + 1.0);
+ let x = dist.inverse_cdf(f);
+ if DEBUG {
+ eprint!("i = {}, f = {:.2}, x = {:.2}; ", i, f, x);
+ }
+ prio.push(x);
+ }
+ if DEBUG { eprintln!("\x08\x08."); }
+ prio.reverse();
+ normalize(prio)
+}
+
+
fn main() {
let ranked: Vec<String> = input();
let num = ranked.len() as i32;
let _prio1 = delta(num);
- let prio2 = exp(num);
+ let _prio2 = exp(num);
+ let prio3 = lognormal(num);
if DEBUG {
for l in ranked.iter() {
eprintln!("\x08\x08.");
}
- output(&prio2, &ranked);
+ output(&prio3, &ranked);
}