use strafe_type::{FloatConstraint, LogProbability64, Probability64, Rational64, Real64};
use crate::traits::DPQ;
pub fn pweibull<RE: Into<Real64>, RA1: Into<Rational64>, RA2: Into<Rational64>>(
x: RE,
shape: RA1,
scale: RA2,
lower_tail: bool,
) -> Probability64 {
let mut x = x.into().unwrap();
let shape = shape.into().unwrap();
let scale = scale.into().unwrap();
if x <= 0.0 {
return f64::dt_0(lower_tail, false).into();
}
x = -(x / scale).powf(shape);
return if lower_tail {
-x.exp_m1()
} else {
x.d_exp(false)
}
.into();
}
pub fn log_pweibull<RE: Into<Real64>, RA1: Into<Rational64>, RA2: Into<Rational64>>(
x: RE,
shape: RA1,
scale: RA2,
lower_tail: bool,
) -> LogProbability64 {
let mut x = x.into().unwrap();
let shape = shape.into().unwrap();
let scale = scale.into().unwrap();
if x <= 0.0 {
return f64::dt_0(lower_tail, true).into();
}
x = -(x / scale).powf(shape);
if lower_tail {
x.log1_exp()
} else {
x.d_exp(true)
}
.into()
}