AgeReplacementModel#
- class relife.model.AgeReplacementModel(baseline)[source]#
Age replacement model.
Lifetime model where the asset is replaced at age \(a_r\).
- Parameters:
- baselineLifetimeModel
Underlying lifetime model.
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
Survival functions
Cumulative hazard function.
Hazard function.
Inverse cumulative hazard function.
Inverse survival function.
Mean residual life.
Survival function.
Statistics
Other methods
Lebesgue-Stieltjes integration.
Random variable sampling.
Attributes
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, ar, *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, ar, *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, *args)#
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, ar, *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, ar, *args, ndim=0, deg=100)[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
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, ar, *args)[source]#
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, ar, *args)[source]#
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, ar, *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(*args, size=1, seed=None)#
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, ar, *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.