use strafe_trait::{
InsignificantCoefficient, RejectionStatus, SignificantCoefficient, Statistic,
StatisticalEstimate,
};
use strafe_type::{Alpha64, FloatConstraint};
#[derive(Clone, Debug)]
pub struct ZCoefficient {
pub name: String,
pub(crate) estimate: f64,
pub(crate) confidence_interval: (f64, f64),
pub(crate) alpha: Alpha64,
pub(crate) z: f64,
pub(crate) p: f64,
}
impl StatisticalEstimate<f64, (f64, f64)> for ZCoefficient {
fn alpha(&self) -> Alpha64 {
self.alpha
}
fn estimate(&self) -> f64 {
self.estimate
}
fn confidence_interval(&self) -> (f64, f64) {
self.confidence_interval
}
}
impl Statistic for ZCoefficient {
fn alpha(&self) -> Alpha64 {
self.alpha
}
fn statistic(&self) -> f64 {
self.z
}
fn probability_value(&self) -> f64 {
self.p
}
fn conclusion(&self) -> RejectionStatus {
if self.p < self.alpha.unwrap() {
RejectionStatus::RejectInFavorOf(Box::new(SignificantCoefficient {}))
} else {
RejectionStatus::FailToReject(Box::new(InsignificantCoefficient {}))
}
}
}