LeftTruncatedModel#

class relife.model.LeftTruncatedModel(baseline)[source]#

Left truncated model.

Conditional distribution of the lifetime model for an asset having reach age \(a_0\).

Parameters:
baselineLifetimeModel

Underlying lifetime model.

Methods

Survival functions

chf

Cumulative hazard function.

hf

Hazard function.

ichf

Inverse cumulative hazard function.

isf

Inverse survival function.

mrl

Mean residual life.

sf

Survival function.

cdf

Cumulative distribution function.

pdf

Probability density function.

ppf

Percent point function.

Statistics

mean

Mean.

median

Median

moment

n-th order moment

var

Variance.

Other methods

ls_integrate

Lebesgue-Stieltjes integration.

rvs

Random variable sampling.

Attributes

plot

Plot

cdf(time, *args)#

Cumulative distribution function.

Parameters:
timefloat or ndarray, shape (n, ) or (m, n)
*argsvariadic arguments required by the function
Returns:
ndarray of shape (), (n, ) or (m, n)

Cumulative distribution function values at each given time.

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

Cumulative hazard function.

Parameters:
timefloat or ndarray, shape (n, ) or (m, n)

Elapsed time.

*argsvariadic arguments required by the function
Returns:
ndarray of shape (), (n, ) or (m, n)

Cumulative hazard values at each given time.

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

Hazard function.

The hazard function of the distribution

Parameters:
timefloat or ndarray, shape (n, ) or (m, n)

Elapsed time.

*argsvariadic arguments required by the function
Returns:
ndarray of shape (), (n, ) or (m, n)

Hazard values at each given time.

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

Inverse cumulative hazard function.

Parameters:
Cumulative hazard ratefloat or ndarray, shape (n, ) or (m, n)
*argsvariadic arguments required by the function
Returns:
ndarray of shape (), (n, ) or (m, n)

Inverse cumulative hazard values, i.e. time.

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

Inverse survival function.

Parameters:
probabilityfloat or ndarray, shape (n, ) or (m, n)
*argsvariadic arguments required by the function
Returns:
ndarray of shape (), (n, ) or (m, n)

Complement quantile corresponding to probability.

ls_integrate(func, a, b, *args, deg=100)#

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

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.

Parameters:
funccallable (in1 ndarray, out1 ndarray)

The callable must have only one ndarray object as argument and returns one ndarray object

andarray (max dim of 2)

Lower bound(s) of integration.

bndarray (max dim of 2)

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

argsndarray (max dim of 2)

Other arguments needed by the lifetime model (eg. covariates)

degint, default 100

Degree of the polynomials interpolation

Returns:
2d ndarray

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

Notes

ls_integrate operations rely on arguments number of dimensions passed in a, b, *args or any other variable referenced in func. Because func callable is not easy to inspect, either one must specify the maximum number of dimensions used (0, 1 or 2), or ls_integrate converts all these objects to 2d-array. Currently, the second option is prefered. That’s why, returns are always 2d-array.

mean(*args)#

Mean.

Parameters:
*argsvariadic arguments required by the function
Returns:
ndarray of shape (0,)

Mean value.

median(*args)#

Median

Parameters:
*argsvariadic arguments required by the function
Returns:
ndarray of shape (0,)

Median value.

moment(n, *args)#

n-th order moment

Parameters:
norder of the moment, at least 1.
*argsvariadic arguments required by the function
Returns:
ndarray of shape (0, )

n-th order moment.

mrl(time, *args)#

Mean residual life.

Parameters:
timefloat or ndarray, shape (n, ) or (m, n)

Elapsed time.

*argsvariadic arguments required by the function
Returns:
ndarray of shape (), (n, ) or (m, n)

Mean residual life values.

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

Probability density function.

Parameters:
timefloat or ndarray, shape (n, ) or (m, n)

Elapsed time.

*argsvariadic arguments required by the function
Returns:
ndarray of shape (), (n, ) or (m, n)

The probability density function evaluated at each given time.

property plot#

Plot

ppf(probability, *args)#

Percent point function.

Parameters:
probabilityfloat or ndarray, shape (n, ) or (m, n)
*argsvariadic arguments required by the function
Returns:
ndarray of shape (), (n, ) or (m, n)

Quantile corresponding to probability.

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

Random variable sampling.

Parameters:
*argsvariadic arguments required by the function
sizeint, default 1

Sized of the generated sample.

seedint, default None

Random seed.

Returns:
ndarray of shape (size, )

Sample of random lifetimes.

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

Survival function.

Parameters:
timefloat or ndarray, shape (n, ) or (m, n)

Elapsed time.

*argsvariadic arguments required by the function
Returns:
ndarray of shape (), (n, ) or (m, n)

Survival function values at each given time.

var(*args)#

Variance.

Parameters:
*argsvariadic arguments required by the function
Returns:
ndarray of shape (0,)

Variance value.