Weibull doc: add PDF and warning against small k (#1509)

This commit is contained in:
Benjamin Lieser 2024-10-16 12:11:24 +02:00 committed by GitHub
parent 695fc9a5f5
commit 9d57b87e27
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -19,6 +19,10 @@ use rand::Rng;
/// scale parameter `λ` (`lambda`) and shape parameter `k`. It is used /// scale parameter `λ` (`lambda`) and shape parameter `k`. It is used
/// to model reliability data, life data, and accelerated life testing data. /// to model reliability data, life data, and accelerated life testing data.
/// ///
/// # Density function
///
/// `f(x; λ, k) = (k / λ) * (x / λ)^(k - 1) * exp(-(x / λ)^k)` for `x >= 0`.
///
/// # Plot /// # Plot
/// ///
/// The following plot shows the Weibull distribution with various values of `λ` and `k`. /// The following plot shows the Weibull distribution with various values of `λ` and `k`.
@ -33,6 +37,11 @@ use rand::Rng;
/// let val: f64 = rand::rng().sample(Weibull::new(1., 10.).unwrap()); /// let val: f64 = rand::rng().sample(Weibull::new(1., 10.).unwrap());
/// println!("{}", val); /// println!("{}", val);
/// ``` /// ```
///
/// # Numerics
///
/// For small `k` like `< 0.005`, even with `f64` a significant number of samples will be so small that they underflow to `0.0`
/// or so big they overflow to `inf`. This is a limitation of the floating point representation and not specific to this implementation.
#[derive(Clone, Copy, Debug, PartialEq)] #[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Weibull<F> pub struct Weibull<F>