torch.distributions.Weibull
class Weibull extends Distributionnew Weibull(scale: number | Tensor, concentration: number | Tensor, options?: DistributionOptions)
- readonly
scale(Tensor) - – Scale parameter (lambda).
- readonly
concentration(Tensor) - – Concentration/shape parameter (k).
- readonly
arg_constraints(unknown) - readonly
support(unknown) - readonly
has_rsample(unknown) - readonly
mean(Tensor) - readonly
mode(Tensor) - readonly
variance(Tensor)
Weibull distribution: continuous distribution for modeling failure rates and lifetimes.
Flexible distribution with adjustable shape (concentration) that can model increasing, constant, or decreasing failure rates. Essential for:
- Reliability engineering (time-to-failure, product lifetime)
- Survival analysis and time-to-event modeling
- Extreme value statistics and risk analysis
- Wind speed and weather modeling (Rayleigh as special case)
- Material strength analysis (Weibull modulus)
- Manufacturing quality control and failure prediction
- Generalization of exponential distribution (k=1) and Rayleigh (k=2)
Parameterized by scale λ (characteristic life) and concentration k (shape). The concentration parameter controls tail behavior: k < 1 → decreasing hazard rate, k = 1 → constant (exponential), k > 1 → increasing hazard rate.
The probability density function: f(x) = (k/λ) * (x/λ)^(k-1) * exp(-(x/λ)^k) where x ≥ 0, λ > 0 (scale), k > 0 (concentration/shape)
Key properties:
- Support: [0, ∞) - non-negative values only
- Mean: λ * Γ(1 + 1/k) where Γ is gamma function
- Median: λ * (ln(2))^(1/k)
- Mode: λ * ((k-1)/k)^(1/k) for k > 1, else 0
- Variance: λ² * [Γ(1 + 2/k) - Γ²(1 + 1/k)]
- Hazard rate (failure rate): h(x) = (k/λ) * (x/λ)^(k-1)
- k < 1: decreasing (infant mortality)
- k = 1: constant (no memory, like exponential)
- k > 1: increasing (wear-out failures)
- Skewness decreases as k increases (approaches normal)
- k = 1 → exponential distribution (memoryless)
- k = 2 → Rayleigh distribution (wind speed)
- k → ∞ → approaches delta function (deterministic)
- Hazard rate control: Shape k directly determines failure rate behavior
- Characteristic life: Scale λ is where 63.2% of population has failed
- Extreme value: Weibull models extremes (min of exponentials under scaling)
- Exponential limit: k → 1 recovers exponential distribution (no memory)
- Rayleigh connection: k = 2 gives Rayleigh, important for wind/distance
- Scale invariance: Distribution scales with λ (no shape change)
- Positive support: k and λ must be strictly positive; domain is [0, ∞)
- Hazard rate: Increasing hazard (k 1) means older items fail faster
- Numerical issues: Very small λ or extreme k values can cause instability
- Mean sensitivity: Mean grows rapidly with shape k due to Gamma function
Examples
// Standard Weibull: scale=1, concentration=2 (Rayleigh distribution)
const weibull = new torch.distributions.Weibull(1, 2);
weibull.sample(); // Similar to Rayleigh(scale=1)
// Reliability modeling: product lifetime with scale=1000 hours
const lambda = 1000; // Characteristic lifetime (63.2% failure by this time)
const k = 1.5; // Increasing failure rate (wear-out behavior)
const reliability = new torch.distributions.Weibull(lambda, k);
const ttf = reliability.sample([1000]); // 1000 time-to-failure samples
// Exponential as special case: k=1 means constant failure rate
const constant_rate = new torch.distributions.Weibull(2, 1);
// Same as Exponential(rate=1/2), memoryless property
// Decreasing failure rate: k < 1 (infant mortality)
const infant_mortality = new torch.distributions.Weibull(5, 0.5);
// High early failure, improves over time
// Wind speed modeling: Rayleigh when k=2
const wind_scale = 10; // Mean wind speed parameter
const wind_dist = new torch.distributions.Weibull(wind_scale, 2);
const wind_speeds = wind_dist.sample([100]); // 100 wind speed samples
// Material strength analysis: Weibull modulus controls variability
const strength_scale = 1000; // MPa
const weibull_modulus = 5; // Higher = more consistent strength
const material = new torch.distributions.Weibull(strength_scale, weibull_modulus);
const strengths = material.sample([10000]); // Distribution of material strengths
// Batched distributions: different failure rates for different components
const scales = torch.tensor([100, 500, 1000]);
const shapes = torch.tensor([0.8, 1.5, 2.0]);
const dists = new torch.distributions.Weibull(scales, shapes);
const samples = dists.sample(); // One sample from each component's lifetime