energy_methods.failure_rates#

Failure counts, exposure, demand probability and censored lifetime models.

Rates are per declared exposure unit, never percentages. Gamma uses shape/rate for uncertainty in a rate; a Gamma lifetime distribution instead uses a scale. No function silently converts a demand probability to an hourly rate.

class energy_methods.failure_rates.RateEstimate(failures, exposure, rate, lower, upper, confidence)[source]#

Bases: object

MLE and central exact Poisson confidence interval, in 1/exposure-unit.

With zero failures the central interval has a one-sided confidence level of (1+confidence)/2. Use zero_failure_upper_bound for a specified one-sided confidence level. Infinity for MTBF does not establish immunity.

Parameters:
  • failures (int)

  • exposure (float)

  • rate (float)

  • lower (float)

  • upper (float)

  • confidence (float)

failures: int#
exposure: float#
rate: float#
lower: float#
upper: float#
confidence: float#
property mtbf: float#

Inverse rate, in the input exposure unit; assumes a constant rate.

energy_methods.failure_rates.estimate_rate(failures, exposure, *, confidence=0.95)[source]#

Estimate k/T, using Garwood bounds for independent fixed-exposure counts.

Exposure is SUMMED at-risk device time (including censored survivors), not calendar duration, MW or the number of recorded failures alone. The interval assumes homogeneous Poisson counts; heterogeneity, clustering, ageing and reporting bias can make it overconfident.

Parameters:
  • failures (int)

  • exposure (float)

  • confidence (float)

Return type:

RateEstimate

energy_methods.failure_rates.zero_failure_upper_bound(exposure, confidence=0.95)[source]#

One-sided rate bound -log(1-confidence)/T when no failures were observed.

Parameters:
  • exposure (float)

  • confidence (float)

Return type:

float

class energy_methods.failure_rates.GammaRate(shape, rate)[source]#

Bases: object

Uncertain constant rate: Gamma(shape, RATE), with rate in exposure units.

Used for industry priors or posterior uncertainty, not lifetime density. Updates require comparable populations, failure definitions and exposure units, and new data independent of the data already used in the prior.

Parameters:
  • shape (float)

  • rate (float)

shape: float#
rate: float#
property mean: float#
interval(confidence=0.95)[source]#
Parameters:

confidence (float)

Return type:

tuple[float, float]

update(failures, exposure)[source]#
Parameters:
  • failures (int)

  • exposure (float)

Return type:

GammaRate

probability_at_least_one(exposure)[source]#

Posterior predictive 1-(rate/(rate+T))**shape, integrating uncertainty.

Parameters:

exposure (float)

Return type:

float

expected_failures(exposure)[source]#
Parameters:

exposure (float)

Return type:

float

predictive_count_interval(exposure, confidence=0.95)[source]#

Equal-tail Gamma-Poisson predictive bounds, including event noise.

Negative-binomial n=shape, p=rate/(rate+exposure). For a fleet, sum exposure first: the uncertain common rate is shared. Discrete interval coverage can exceed the nominal level. This is not a rate interval.

Parameters:
  • exposure (float)

  • confidence (float)

Return type:

tuple[int, int]

predictive_log_probability(failures, exposure)[source]#

Log predictive probability of a future count for out-of-time scoring.

Parameters:
  • failures (int)

  • exposure (float)

Return type:

float

class energy_methods.failure_rates.BetaDemand(alpha, beta)[source]#

Bases: object

Beta uncertainty in a per-demand failure probability, not a time rate.

Parameters:
  • alpha (float)

  • beta (float)

alpha: float#
beta: float#
property mean: float#
interval(confidence=0.95)[source]#
Parameters:

confidence (float)

Return type:

tuple[float, float]

update(failures, demands)[source]#
Parameters:
  • failures (int)

  • demands (int)

Return type:

BetaDemand

probability_at_least_one(demands)[source]#

Beta-binomial predictive probability, for conditionally iid demands.

Parameters:

demands (int)

Return type:

float

class energy_methods.failure_rates.LifetimeModel(kind, parameter1, parameter2=1.0)[source]#

Bases: object

Time-to-event model with explicit parameter conventions and time units.

Weibull: (shape, scale); gamma: (shape, SCALE); exponential: (rate, unused); lognormal_log: (underlying-normal mean, standard deviation). Normal is explicitly conditioned on lifetime >= 0, an implementation adaptation. Fits to recurring fault intervals are not component lifetimes.

Parameters:
  • kind (Literal['weibull', 'gamma', 'exponential', 'lognormal_log', 'normal_positive'])

  • parameter1 (float)

  • parameter2 (float)

kind: Literal['weibull', 'gamma', 'exponential', 'lognormal_log', 'normal_positive']#
parameter1: float#
parameter2: float = 1.0#
log_survival(time)[source]#

Log S(t), with t measured in the model’s documented time unit.

Parameters:

time (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str])

Return type:

ndarray[tuple[Any, …], dtype[float64]]

conditional_failure(age, horizon)[source]#

1-S(age+horizon)/S(age); not an expected renewal failure count.

Parameters:
  • age (float)

  • horizon (float)

Return type:

float

energy_methods.failure_rates.fit_weibull_censored(times, failed)[source]#

Two-parameter Weibull MLE with independent right censoring.

One row per device, observed from age zero. failed is 0 or 1. Include survivors; no delayed entry, interval censoring or recurrent-event fitting. Raises for unidentified fits rather than assigning an arbitrary lifetime.

Parameters:
  • times (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str])

  • failed (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str])

Return type:

LifetimeModel