survival 1.0.17

A high-performance survival analysis library written in Rust with Python bindings
Documentation
use pyo3::prelude::*;
use statrs::distribution::{ContinuousCDF, Normal};
fn probit(p: f64) -> f64 {
    let normal =
        Normal::new(0.0, 1.0).expect("standard normal distribution parameters are always valid");
    normal.inverse_cdf(p)
}
fn cloglog(p: f64) -> f64 {
    (-(1.0 - p).ln()).ln()
}
#[pyclass]
pub struct LinkFunctionParams {
    edge: f64,
}
#[pymethods]
impl LinkFunctionParams {
    #[new]
    fn new(edge: f64) -> Self {
        LinkFunctionParams { edge }
    }
    fn blogit(&self, input: f64) -> f64 {
        let adjusted_input = if input < self.edge {
            self.edge
        } else if input > 1.0 - self.edge {
            1.0 - self.edge
        } else {
            input
        };
        adjusted_input.ln() - (1.0 - adjusted_input).ln()
    }
    fn bprobit(&self, input: f64) -> f64 {
        let adjusted_input = if input < self.edge {
            self.edge
        } else if input > 1.0 - self.edge {
            1.0 - self.edge
        } else {
            input
        };
        probit(adjusted_input) - probit(1.0 - adjusted_input)
    }
    fn bcloglog(&self, input: f64) -> f64 {
        let adjusted_input = if input < self.edge {
            self.edge
        } else if input > 1.0 - self.edge {
            1.0 - self.edge
        } else {
            input
        };
        cloglog(adjusted_input) - cloglog(1.0 - adjusted_input)
    }
    fn blog(&self, input: f64) -> f64 {
        let adjusted_input = if input < self.edge { self.edge } else { input };
        adjusted_input.ln()
    }
}