pub struct ReliabilityAnalysis { /* private fields */ }Expand description
Reliability analysis results from a fitted Weibull distribution.
Computes reliability engineering metrics (reliability function, hazard rate, MTBF, B-life) from Weibull shape (beta) and scale (eta) parameters.
§Mathematical Background
Given a Weibull distribution with shape beta > 0 and scale eta > 0:
- Reliability: R(t) = exp(-(t/eta)^beta)
- Hazard rate: lambda(t) = (beta/eta) * (t/eta)^(beta-1)
- MTBF: eta * Gamma(1 + 1/beta)
§Examples
use u_analytics::weibull::ReliabilityAnalysis;
let ra = ReliabilityAnalysis::new(2.0, 100.0).unwrap();
assert!((ra.reliability(0.0) - 1.0).abs() < 1e-10);
assert!(ra.hazard_rate(50.0) > 0.0);
assert!(ra.mtbf() > 0.0);
let b10 = ra.b_life(0.10).unwrap();
assert!(b10 > 0.0 && b10 < 100.0);§References
- Meeker & Escobar (1998), Statistical Methods for Reliability Data, Wiley.
- Nelson, W. (1982). Applied Life Data Analysis, Wiley. §2.
- Lawless, J.F. (2003). Statistical Models and Methods for Lifetime Data, 2nd ed.
Implementations§
Source§impl ReliabilityAnalysis
impl ReliabilityAnalysis
Sourcepub fn new(shape: f64, scale: f64) -> Option<Self>
pub fn new(shape: f64, scale: f64) -> Option<Self>
Creates a new reliability analysis from Weibull parameters.
§Arguments
shape- Shape parameter beta (must be positive and finite)scale- Scale parameter eta (must be positive and finite)
§Returns
None if either parameter is non-positive or non-finite.
§Examples
use u_analytics::weibull::ReliabilityAnalysis;
let ra = ReliabilityAnalysis::new(2.0, 100.0);
assert!(ra.is_some());
// Invalid parameters return None
assert!(ReliabilityAnalysis::new(-1.0, 100.0).is_none());
assert!(ReliabilityAnalysis::new(2.0, 0.0).is_none());Sourcepub fn with_covariance(self, covariance: [[f64; 2]; 2]) -> Option<Self>
pub fn with_covariance(self, covariance: [[f64; 2]; 2]) -> Option<Self>
The same analysis with the covariance of the estimated (shape, scale) – row and column order shape, scale, as
WeibullMleResult::covariance
gives it – so the B-lives and reliabilities carry confidence
intervals (Self::b_life_interval, Self::reliability_interval).
None unless the matrix is a covariance: finite, symmetric (to a
relative 1e-9) and positive definite.
§Examples
use u_analytics::weibull::ReliabilityAnalysis;
let ra = ReliabilityAnalysis::new(2.0, 100.0).unwrap();
assert!(ra.clone().with_covariance([[0.04, 0.1], [0.1, 25.0]]).is_some());
assert!(ra.with_covariance([[0.04, 2.0], [2.0, 25.0]]).is_none()); // not positive definiteSourcepub fn covariance(&self) -> Option<[[f64; 2]; 2]>
pub fn covariance(&self) -> Option<[[f64; 2]; 2]>
The covariance of (shape, scale) the intervals are made from, when
there is one.
Sourcepub fn from_mle(result: &WeibullMleResult) -> Self
pub fn from_mle(result: &WeibullMleResult) -> Self
Creates a reliability analysis from an MLE fitting result.
§Panics
This function does not panic. MLE results always have valid parameters.
The fit’s covariance comes along, so the analysis gives confidence intervals.
Sourcepub fn from_mrr(result: &WeibullMrrResult) -> Self
pub fn from_mrr(result: &WeibullMrrResult) -> Self
Creates a reliability analysis from an MRR fitting result.
§Panics
This function does not panic. MRR results always have valid parameters.
Sourcepub fn reliability(&self, t: f64) -> f64
pub fn reliability(&self, t: f64) -> f64
Reliability (survival) function at time t.
R(t) = exp(-(t/eta)^beta)For t < 0, returns 1.0 (no failure before time 0).
§Examples
use u_analytics::weibull::ReliabilityAnalysis;
let ra = ReliabilityAnalysis::new(2.0, 100.0).unwrap();
// R(0) = 1.0 (full reliability at time zero)
assert!((ra.reliability(0.0) - 1.0).abs() < 1e-10);
// R(eta) = exp(-1) ≈ 0.368 for any shape parameter
let expected = (-1.0_f64).exp();
assert!((ra.reliability(100.0) - expected).abs() < 1e-10);§Reference
Weibull (1951), Journal of Applied Mechanics 18(3), pp. 293-297.
Sourcepub fn hazard_rate(&self, t: f64) -> f64
pub fn hazard_rate(&self, t: f64) -> f64
Failure rate (hazard function) at time t.
lambda(t) = (beta/eta) * (t/eta)^(beta-1)- beta < 1: Decreasing failure rate (infant mortality)
- beta = 1: Constant failure rate (random/exponential failures)
- beta > 1: Increasing failure rate (wear-out)
For t <= 0, returns 0.0.
§Examples
use u_analytics::weibull::ReliabilityAnalysis;
let ra = ReliabilityAnalysis::new(2.0, 100.0).unwrap();
// Hazard rate is positive for t > 0
assert!(ra.hazard_rate(50.0) > 0.0);
// With beta > 1, hazard rate increases over time (wear-out)
assert!(ra.hazard_rate(50.0) < ra.hazard_rate(80.0));§Reference
Meeker & Escobar (1998), Statistical Methods for Reliability Data, Ch. 4.
Sourcepub fn mtbf(&self) -> f64
pub fn mtbf(&self) -> f64
Mean Time Between Failures (MTBF).
MTBF = eta * Gamma(1 + 1/beta)§Examples
use u_analytics::weibull::ReliabilityAnalysis;
let ra = ReliabilityAnalysis::new(2.0, 100.0).unwrap();
let mtbf = ra.mtbf();
assert!(mtbf > 0.0);
// For beta=1 (exponential), MTBF = eta
let exp_ra = ReliabilityAnalysis::new(1.0, 50.0).unwrap();
assert!((exp_ra.mtbf() - 50.0).abs() < 1e-8);§Reference
Johnson, Kotz & Balakrishnan (1994), Continuous Univariate Distributions, Vol. 1, Chapter 21.
Sourcepub fn time_to_reliability(&self, p: f64) -> Option<f64>
pub fn time_to_reliability(&self, p: f64) -> Option<f64>
Sourcepub fn b_life(&self, fraction_failed: f64) -> Option<f64>
pub fn b_life(&self, fraction_failed: f64) -> Option<f64>
B-life: time at which a given fraction of the population has failed.
B10 life (10% failed) = b_life(0.10), which is equivalent to
time_to_reliability(0.90).
§Arguments
fraction_failed- Fraction of population that has failed, must be in (0, 1).
§Returns
None if fraction_failed is outside (0, 1).
§Examples
use u_analytics::weibull::ReliabilityAnalysis;
let ra = ReliabilityAnalysis::new(2.0, 100.0).unwrap();
// B10: time when 10% of the population has failed
let b10 = ra.b_life(0.10).unwrap();
assert!(b10 > 0.0 && b10 < 100.0);
// B-lives increase with failure fraction: B5 < B10 < B50
let b5 = ra.b_life(0.05).unwrap();
let b50 = ra.b_life(0.50).unwrap();
assert!(b5 < b10 && b10 < b50);§Reference
Abernethy (2006), The New Weibull Handbook, 5th ed., Chapter 2.
Sourcepub fn b_life_interval(
&self,
fraction_failed: f64,
confidence: f64,
) -> Option<(f64, WeibullInterval)>
pub fn b_life_interval( &self, fraction_failed: f64, confidence: f64, ) -> Option<(f64, WeibullInterval)>
The B-life at fraction_failed with its two-sided interval at
confidence, by the delta method on
ln t_p = ln η + ln(−ln(1 − p)) / β (normal on the log scale, so the
limits stay positive).
Returns (estimate, interval); None without a covariance
(Self::with_covariance, Self::from_mle) or when either argument
is outside (0, 1).
§Examples
use u_analytics::weibull::ReliabilityAnalysis;
let ra = ReliabilityAnalysis::new(2.0, 100.0)
.unwrap()
.with_covariance([[0.04, 0.1], [0.1, 25.0]])
.unwrap();
let (b10, ci) = ra.b_life_interval(0.10, 0.90).unwrap();
assert!(ci.lower < b10 && b10 < ci.upper);§Reference
Meeker & Escobar (1998), Statistical Methods for Reliability Data, §8.4.
Sourcepub fn reliability_interval(
&self,
t: f64,
confidence: f64,
) -> Option<(f64, WeibullInterval)>
pub fn reliability_interval( &self, t: f64, confidence: f64, ) -> Option<(f64, WeibullInterval)>
The reliability R(t) with its two-sided interval at confidence, by
the delta method on u = ln(−ln R(t)) = β (ln t − ln η), which is
unbounded – so the limits exp(−exp(u ± z·se)) stay inside (0, 1).
At t ≤ 0 the model has no failures and the interval is [1, 1].
Returns (estimate, interval); None without a covariance or when
confidence is outside (0, 1) or t is not finite.
§Examples
use u_analytics::weibull::ReliabilityAnalysis;
let ra = ReliabilityAnalysis::new(2.0, 100.0)
.unwrap()
.with_covariance([[0.04, 0.1], [0.1, 25.0]])
.unwrap();
let (r, ci) = ra.reliability_interval(50.0, 0.95).unwrap();
assert!(0.0 < ci.lower && ci.lower < r && r < ci.upper && ci.upper < 1.0);§Reference
Meeker & Escobar (1998), Statistical Methods for Reliability Data, §8.4.