AgeReplacementModel#
- class relife.lifetime_model.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_paramsNumber of parameters.
paramsParameters values.
params_namesParameters names.
plotProvides access to plotting functionnalities
Methods
The cumulative density function.
The cumulative hazard function.
Freeze age replacement values and other arguments into the object data.
The hazard function.
Inverse cumulative hazard function.
The inverse survival function.
Lebesgue-Stieltjes integration.
The mean of the distribution.
The median.
n-th order moment.
The mean residual life function.
The probability density function.
The percent point function.
Random variable sampling.
The survival function.
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
- 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).
- property nb_params#
Number of parameters.
- Returns:
- int
Number of parameters.
- property params#
Parameters values.
- Returns:
- ndarray
Parameters values
Notes
If parameter values are not set, they are encoded as np.nan value.
- property 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.
- 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).
- property plot#
Provides access to plotting functionnalities
- 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, return_event=False, return_entry=False, 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,) as only one age of replacement per asset can be given
- *argsfloat or np.ndarray
Additional arguments needed by the model.
- return_eventbool, default is False
If True, returns event indicators along with the sample time values.
- return_entrybool, default is False
If True, returns corresponding entry values of the sample time values.
- 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:
- float, ndarray or tuple of float or ndarray
The sample values. If either
return_eventorreturn_entryis True, returns a tuple containing the time values followed by event values, entry values or both.
Notes
If
return_entryis true, returned time values are not residual time. Otherwise, the times are residuals
- 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).