Weibull
DistributionWeibull(scale: Tensor | float, concentration: Tensor | float, validate_args: bool | None = None)Weibull distribution — a flexible family for lifetime and survival analysis.
Weibull(scale=λ, concentration=k) generalises both the Exponential
() and Rayleigh () distributions. It is widely
used for modelling time-to-failure data because the hazard rate
can increase, be constant,
or decrease depending on .
Parameters
scaleTensor | floatconcentrationTensor | floatvalidate_argsbool | None= NoneTrue, validate parameter constraints at construction time.Attributes
scaleTensorconcentrationTensorNotes
PDF:
Log-PDF:
Moments:
- Mean:
- Variance:
Entropy:
where is the Euler–Mascheroni constant.
Reparameterised sampling uses the inverse-CDF: for .
Examples
>>> import lucid
>>> from lucid.distributions import Weibull
>>> # Exponential(rate=1) as a special case
>>> dist_exp = Weibull(scale=1.0, concentration=1.0)
>>> dist = Weibull(scale=2.0, concentration=1.5)
>>> samples = dist.rsample((500,))Methods (7)
__init__
→None__init__(scale: Tensor | float, concentration: Tensor | float, validate_args: bool | None = None)Initialise a Weibull distribution.
Parameters
scaleTensor | floatconcentrationTensor | floatvalidate_argsbool | None= NoneTrue, validate parameter constraints at construction time.support
→Constraintsupport: ConstraintSupport of the Weibull distribution: .
Returns
ConstraintThe nonnegative constraint.
mean
→Tensormean: TensorMean of the Weibull distribution: .
Returns
TensorMean values of shape batch_shape.
variance
→Tensorvariance: TensorVariance of the Weibull distribution.
Returns
TensorVariance values of shape batch_shape.
rsample
→Tensorrsample(sample_shape: tuple[int, ...] = ())Draw reparameterised samples via the inverse-CDF.
Uses for
. Gradients propagate
through both scale and concentration.
Parameters
sample_shapetuple[int, ...]= ()Returns
TensorNon-negative samples of shape (*sample_shape, *batch_shape).
log_prob
→Tensorlog_prob(value: Tensor)Log-probability density of the Weibull distribution.
Parameters
valueTensorReturns
TensorLog-density values of the same shape as value.
entropy
→Tensorentropy()Entropy of the Weibull distribution.
where is the Euler-Mascheroni constant.
Returns
TensorEntropy values of shape batch_shape (nats).