relife.model.AgeReplacementModel

relife.model.AgeReplacementModel

class relife.model.AgeReplacementModel(baseline: relife.model.LifetimeModel)[source]

Bases: relife.model.LifetimeModel

Age replacement model.

Lifetime model where the asset is replaced at age ar.

Notes

This is equivalent to the distribution of \(\min(X,a_r)\) where \(X\) is a baseline lifetime model and ar the age of replacement.

Methods

cdf

Cumulative distribution function.

isf

Inverse survival function.

ls_integrate

Lebesgue-Stieltjes integration.

mean

Mean of the distribution.

median

Median of the distribution.

moment

N-th order moment of the distribution.

mrl

Mean residual life.

pdf

Probability density function.

ppf

Percent point function.

rvs

Random variable sampling.

sf

Survival (or reliability) function of the lifetime model.

support_upper_bound

Support upper bound of the lifetime model.

var

Variance of the distribution.

Attributes

baseline

Underlying lifetime model of the asset.

baseline: relife.model.LifetimeModel

Underlying lifetime model of the asset.

support_upper_bound(ar: numpy.ndarray, *args: numpy.ndarray) numpy.ndarray[source]

Support upper bound of the lifetime model.

Parameters

*args (float or 2D array, optional) – Extra arguments required by the lifetime model.

Returns

The support upper bound of the lifetime model with respect to the extra arguments.

Return type

float or ndarray

sf(t: numpy.ndarray, ar: numpy.ndarray, *args: numpy.ndarray) numpy.ndarray[source]

Survival (or reliability) function of the lifetime model.

Parameters
  • t (float or 1D array) – Elapsed time.

  • *args (float or 2D array, optional) – Extra arguments required by the lifetime model.

Returns

The survival function evaluated at t with extra arguments args.

Return type

float or ndarray

Notes

If args are of type ndarray, the arrays should be broadcastable with shape[-1]=1.

The shape of the result will be:

np.broadcast_shapes(*(np.shape(arg) for arg in args))[:-1] + (np.size(t),)
pdf(t: numpy.ndarray, ar: numpy.ndarray, *args: numpy.ndarray) numpy.ndarray[source]

Probability density function.

Parameters
  • t (float or 1D array) – Elapsed time.

  • *args (float or 2D array, optional) – Extra arguments required by the lifetime model.

Returns

The probability density function evaluated at t with extra arguments args.

Return type

float or ndarray

Notes

If args are of type ndarray, the arrays should be broadcastable with shape[-1]=1.

The shape of the result will be:

np.broadcast_shapes(*(np.shape(arg) for arg in args))[:-1] + (np.size(t),)
isf(p: numpy.ndarray, ar: numpy.ndarray, *args: numpy.ndarray) numpy.ndarray[source]

Inverse survival function.

Parameters
  • p (float or 1D array) – Probability.

  • *args (float or 2D array, optional) – Extra arguments required by the lifetime model.

Returns

Complement quantile corresponding to p.

Return type

float or ndarray

Notes

If args are of type ndarray, the arrays should be broadcastable with shape[-1]=1.

The shape of the result will be:

np.broadcast_shapes(*(np.shape(arg) for arg in args))[:-1] + (np.size(p),)
ls_integrate(func: Callable, a: numpy.ndarray, b: numpy.ndarray, ar: numpy.ndarray, *args: numpy.ndarray, ndim: int = 0, deg: int = 100) numpy.ndarray[source]

Lebesgue-Stieltjes integration.

The Lebesgue-Stieljes intregration of a function with respect to the lifetime model taking into account the probability density function and jumps.

Parameters
  • func (Callable) – Function or method to integrate on interval [a,b] integrated with respect to the lifetime model.

  • a (float or 1D array) – Lower bound of integration.

  • b (float or 1D array) – Upper bound of integration (use numpy.inf for +infinity).

  • *args (float or 2D array, optional) – Extra arguments required by the lifetime model.

  • **kwargs (int or float) – Extra keyword arguments required for the Lebesgue-Stieljes integration.

Returns

Lebesgue-Stieltjes integral of func with respect to cdf from a to b.

Return type

float or ndarray

Notes

The Lebesgue-Stieltjes integral is:

\[\int_a^b g(x) \mathrm{d}F(x) = \int_a^b g(x) f(x)\mathrm{d}x + \sum_i g(a_i) w_i\]

where:

  • \(F\) is the cumulative distribution function,

  • \(f\) the probability density function of the lifetime model,

  • \(a_i\) and \(w_i\) are the points and weights of the jumps.

1

Resnick, S. I. (1992). Adventures in stochastic processes. Springer Science & Business Media. p176.

cdf(t: numpy.ndarray, *args: numpy.ndarray) numpy.ndarray

Cumulative distribution function.

Parameters
  • t (float or 1D array) – Elapsed time.

  • *args (float or 2D array, optional) – Extra arguments required by the lifetime model.

Returns

Cumulative distribution function at t with extra args .

Return type

float or ndarray

Notes

If args are of type ndarray, the arrays should be broadcastable with shape[-1]=1.

The shape of the result will be:

np.broadcast_shapes(*(np.shape(arg) for arg in args))[:-1] + (np.size(t),)
mean(*args: numpy.ndarray) numpy.ndarray

Mean of the distribution.

The mean of a distribution is the moment of the first order.

Parameters

*args (float or 2D array, optional) – Extra arguments required by the lifetime model.

Returns

Mean of the distribution.

Return type

float or ndarray

Notes

If args are of type ndarray, the arrays should be broadcastable with shape[-1]=1.

The shape of the result will be:

np.broadcast_shapes(*(np.shape(arg) for arg in args))[:-1] + (1,)
median(*args: numpy.ndarray) numpy.ndarray

Median of the distribution.

The median is the ppf evaluated at 0.5.

Parameters

*args (float or 2D array, optional) – Extra arguments required by the lifetime model.

Returns

The median of the distribution.

Return type

float or ndarray

Notes

If args are of type ndarray, the arrays should be broadcastable with shape[-1]=1.

The shape of the result will be:

np.broadcast_shapes(*(np.shape(arg) for arg in args))[:-1] + (1,)
moment(n: int, *args: numpy.ndarray) numpy.ndarray

N-th order moment of the distribution.

The n-th order moment is the Lebegue-Stieljes integral of x**n with respect to the cdf.

Parameters
  • n (int, n >=1) – Order of moment.

  • *args (float or 2D array, optional) – Extra arguments required by the lifetime model.

Returns

N-th order moment of the distribution.

Return type

float or ndarray

Notes

If args are of type ndarray, the arrays should be broadcastable with shape[-1]=1.

The shape of the result will be:

np.broadcast_shapes(*(np.shape(arg) for arg in args))[:-1] + (1,)
mrl(t: numpy.ndarray, *args: numpy.ndarray) numpy.ndarray

Mean residual life.

The mean residual life for an asset aged t is the mean of the lifetime distribution truncated at t on the interval [t,ub).

Parameters
  • t (float or 1D array) – Age of the asset

  • *args (float or 2D array, optional) – Extra arguments required by the lifetime model.

Returns

The mean residual life of assets at age t.

Return type

float or ndarray

Notes

If args are of type ndarray, the arrays should be broadcastable with shape[-1]=1.

The shape of the result will be:

np.broadcast_shapes(*(np.shape(arg) for arg in args))[:-1] + (np.size(t),).

The mean residual life is:

\[\mu(t) = \dfrac{\int_t^{\infty} (x - t) \mathrm{d}F(x)}{S(t)}\]

where \(F\) is the cumulative distribution function and \(S\) is the survival function.

ppf(p: numpy.ndarray, *args: numpy.ndarray) numpy.ndarray

Percent point function.

The ppf is the inverse of cdf.

Parameters
  • p (float or 1D array) – Probability.

  • *args (float or 2D array, optional) – Extra arguments required by the lifetime model.

Returns

Quantile corresponding to p.

Return type

float or ndarray

Notes

If args are of type ndarray, the arrays should be broadcastable with shape[-1]=1.

The shape of the result will be:

np.broadcast_shapes(*(np.shape(arg) for arg in args))[:-1] + (np.size(p),)
rvs(*args: numpy.ndarray, size: int = 1, random_state: Optional[int] = None) numpy.ndarray

Random variable sampling.

Parameters
  • *args (float or 2D array, optional) – Extra arguments required by the lifetime model.

  • size (int, optional) – Size of sample, by default 1.

  • random_state (int, optional) – Random seed, by default None.

Returns

Sample of random variates with shape[-1]=size.

Return type

float or ndarray

Notes

If args are of type ndarray, the arrays should be broadcastable with shape[-1]=1.

The shape of the result will be:

np.broadcast_shapes(*(np.shape(arg) for arg in args))[:-1] + (size,)
var(*args: numpy.ndarray) numpy.ndarray

Variance of the distribution.

Parameters

*args (float or 2D array, optional) – Extra arguments required by the lifetime model.

Returns

Variance of the distribution.

Return type

float or ndarray

Notes

If args are of type ndarray, the arrays should be broadcastable with shape[-1]=1.

The shape of the result will be:

np.broadcast_shapes(*(np.shape(arg) for arg in args))[:-1] + (1,)