AgeReplacementModel#

class relife.lifetime_models.AgeReplacementModel(baseline)[source]#

Age replacement model.

Lifetime model where the assets are replaced at age \(a_r\). This is equivalent to the model of \(\min(X,a_r)\) where \(X\) is a baseline lifetime and \(a_r\) is the age of replacement.

Parameters:
baselineany parametric lifetime model (frozen lifetime model works)

The base lifetime model without conditional probabilities

Attributes:
baseline
nb_params
params
params_names
plot

Methods

cdf

The cumulative density function.

chf

The cumulative hazard function.

freeze

Freeze age replacement values and other arguments into the object data.

get_params

Get the parameters of this model.

get_params_names

Parameters names.

hf

The hazard function.

ichf

Inverse cumulative hazard function.

isf

The inverse survival function.

ls_integrate

Lebesgue-Stieltjes integration.

mean

The mean of the distribution.

median

The median.

moment

n-th order moment.

mrl

The mean residual life function.

pdf

The probability density function.

plot

ppf

The percent point function.

rvs

Random variable sampling.

set_params

Set the parameters of this model.

sf

The survival function.

var

The variance of the distribution.

cdf(time, ar, *args)[source]#

The cumulative density function.

Parameters:
timefloat or np.ndarray

Elapsed time value(s) at which to compute the function. If ndarray, allowed shapes are (), (n,) or (m, n).

arfloat or np.ndarray

Age of replacement values.

If ndarray, shape can only be (m,) because only one age of replacement per asset can be given.

*args

Any other arguments needed by the model.

Returns:
outnp.float64 or np.ndarray

cdf values at each given time(s).

chf(time, ar, *args)[source]#

The cumulative hazard function.

Parameters:
timefloat or np.ndarray

Elapsed time value(s) at which to compute the function. If ndarray, allowed shapes are (), (n,) or (m, n).

arfloat or np.ndarray

Age of replacement values.

If ndarray, shape can only be (m,) because only one age of replacement per asset can be given.

*args

Any other arguments needed by the model.

Returns:
outnp.float64 or np.ndarray

chf values at each given time(s).

freeze(ar, *args)[source]#

Freeze age replacement values and other arguments into the object data.

Parameters:
arfloat or np.ndarray

Age of replacement values. If ndarray, shape can only be (m,) as only one age of replacement per asset can be given

*argsfloat or np.ndarray

Additional arguments needed by the model.

Returns:
FrozenParametricModel
get_params()#

Get the parameters of this model.

Returns:
out1darray of number

Model parameters.

Notes

If parameter values are not set, they default to np.nan values.

get_params_names()#

Parameters names.

Returns:
list of str

Parameters names

Notes

Parameters values can be requested (a.k.a. get) by their name at instance level.

hf(time, ar, *args)[source]#

The hazard function.

Parameters:
timefloat or np.ndarray

Elapsed time value(s) at which to compute the function. If ndarray, allowed shapes are (), (n,) or (m, n).

arfloat or np.ndarray

Age of replacement values.

If ndarray, shape can only be (m,) because only one age of replacement per asset can be given.

*args

Any other arguments needed by the model.

Returns:
outnp.float64 or np.ndarray

hf values at each given time(s).

ichf(cumulative_hazard_rate, ar, *args)[source]#

Inverse cumulative hazard function.

Parameters:
cumulative_hazard_ratefloat or np.ndarray

Cumulative hazard rate value(s) at which to compute the function. If ndarray, allowed shapes are (), (n,) or (m, n).

arfloat or np.ndarray

Age of replacement values.

If ndarray, shape can only be (m,) because only one age of replacement per asset can be given.

*args

Any other arguments needed by the model.

Returns:
outnp.float64 or np.ndarray

ichf values at each given cumulative hazard rate(s).

isf(probability, ar, *args)[source]#

The inverse survival function.

Parameters:
probabilityfloat or np.ndarray

Probability value(s) at which to compute the function. If ndarray, allowed shapes are (), (n,) or (m, n).

arfloat or np.ndarray

Age of replacement values.

If ndarray, shape can only be (m,) because only one age of replacement per asset can be given.

*args

Any other arguments needed by the model.

Returns:
outnp.float64 or np.ndarray

isf values at each given probability value(s).

ls_integrate(func, a, b, ar, *args, deg=10)[source]#

Lebesgue-Stieltjes integration.

Parameters:
funccallable (in1 ndarray , out1 ndarray)

The callable must have only one ndarray object as argument and one ndarray object as output.

andarray (maximum number of dimension is 2)

Lower bound(s) of integration.

bndarray (maximum number of dimension is 2)

Upper bound(s) of integration. If lower bound(s) is infinite, use np.inf as value.

arfloat or np.ndarray

Age of replacement values.

If ndarray, shape can only be (m,) because only one age of replacement per asset can be given.

*args

Any other arguments needed by the model.

degint, default 10

Degree of the polynomials interpolation.

Returns:
outnp.ndarray

Lebesgue-Stieltjes integral of func from a to b.

mean(ar, *args)[source]#

The mean of the distribution.

Parameters:
arfloat or np.ndarray

Age of replacement values.

If ndarray, shape can only be (m,) because only one age of replacement per asset can be given.

*args

Any other arguments needed by the model.

Returns:
outnp.float64 or np.ndarray
median(ar, *args)[source]#

The median.

Parameters:
arfloat or np.ndarray

Age of replacement values.

If ndarray, shape can only be (m,) because only one age of replacement per asset can be given.

*args

Any other arguments needed by the model.

Returns:
outnp.float64 or np.ndarray
moment(n, ar, *args)[source]#

n-th order moment.

Parameters:
nint

order of the moment, at least 1.

arfloat or np.ndarray

Age of replacement values.

If ndarray, shape can only be (m,) because only one age of replacement per asset can be given.

*args

Any other arguments needed by the model.

Returns:
outnp.float64
mrl(time, ar, *args)[source]#

The mean residual life function.

Parameters:
timefloat or np.ndarray

Elapsed time value(s) at which to compute the function. If ndarray, allowed shapes are (), (n,) or (m, n).

arfloat or np.ndarray

Age of replacement values.

If ndarray, shape can only be (m,) because only one age of replacement per asset can be given.

*args

Any other arguments needed by the model.

Returns:
outnp.float64 or np.ndarray

Function values at each given time(s).

pdf(time, ar, *args)[source]#

The probability density function.

Parameters:
timefloat or np.ndarray

Elapsed time value(s) at which to compute the function. If ndarray, allowed shapes are (), (n,) or (m, n).

arfloat or np.ndarray

Age of replacement values.

If ndarray, shape can only be (m,) because only one age of replacement per asset can be given.

*args

Any other arguments needed by the model.

Returns:
outnp.float64 or np.ndarray

pdf values at each given time(s).

ppf(probability, ar, *args)[source]#

The percent point function.

Parameters:
probabilityfloat or np.ndarray

Probability value(s) at which to compute the function. If ndarray, allowed shapes are (), (n,) or (m, n).

arfloat or np.ndarray

Age of replacement values.

If ndarray, shape can only be (m,) because only one age of replacement per asset can be given.

*args

Any other arguments needed by the model.

Returns:
outnp.float64 or np.ndarray

ppf values at each given probability value(s).

rvs(size, ar, *args, seed=None)[source]#

Random variable sampling.

Parameters:
sizeint or tuple (m, n) of int

Size of the generated sample.

arfloat or np.ndarray

Age of replacement values.

If ndarray, shape can only be (m,) because only one age of replacement per asset can be given.

*args

Any other arguments needed by the model.

seedoptional int, np.random.BitGenerator, np.random.Generator, np.random.RandomState, default is None

If int or BitGenerator, seed for random number generator. If np.random.RandomState or np.random.Generator, use as given.

Returns:
outfloat or ndarray

The sample values.

set_params(new_params)#

Set the parameters of this model.

Parameters:
new_paramsarray-like of floats

Model parameters.

Notes

set_params definition expects an array-like of floats. At runtime, complex parameters might be setted temporarily to approximate fitted parameters covariance. This is contradictory to the given typing. At the moment, we don’t see a better solution and we believe that this is actually a limitation of what be expressed in the static typesystem.

sf(time, ar, *args)[source]#

The survival function.

Parameters:
timefloat or np.ndarray

Elapsed time value(s) at which to compute the function. If ndarray, allowed shapes are (), (n,) or (m, n).

arfloat or np.ndarray

Age of replacement values.

If ndarray, shape can only be (m,) because only one age of replacement per asset can be given.

*args

Any other arguments needed by the model.

Returns:
outnp.float64 or np.ndarray

sf values at each given time(s).

var(ar, *args)[source]#

The variance of the distribution.

Parameters:
arfloat or np.ndarray

Age of replacement values.

If ndarray, shape can only be (m,) because only one age of replacement per asset can be given.

*args

Any other arguments needed by the model.

Returns:
outnp.float64 or np.ndarray