Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weibull doc numerics warning #1509

Merged
merged 2 commits into from
Oct 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions rand_distr/src/weibull.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ use rand::Rng;
/// scale parameter `λ` (`lambda`) and shape parameter `k`. It is used
/// 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
///
/// The following plot shows the Weibull distribution with various values of `λ` and `k`.
Expand All @@ -33,6 +37,11 @@ use rand::Rng;
/// let val: f64 = rand::rng().sample(Weibull::new(1., 10.).unwrap());
/// 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)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Weibull<F>
Expand Down