r2rs-stats 0.1.1

Statistics programming for Rust based on R's stats package
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use strafe_type::Probability64;

pub fn ppoints(n: usize, a: Option<f64>) -> Vec<Probability64> {
    let a = if let Some(a) = a {
        a
    } else {
        if n <= 10 {
            3.0 / 8.0
        } else {
            0.5
        }
    };

    (1..=n)
        .map(|f| ((f as f64 - a) / (n as f64 + 1.0 - 2.0 * a)).into())
        .collect()
}