LeftTruncatedModel#
- class relife.lifetime_models.LeftTruncatedModel(baseline)[source]#
Left truncated model.
Lifetime model where the assets have already reached the age \(a_0\).
- Parameters:
- baselineany parametric lifetime model (frozen lifetime model works)
The base lifetime model without conditional probabilities
- nb_params
- params
- params_names
- plot
- Attributes:
- baseline
- nb_params
- params
- params_names
- plot
Methods
The cumulative density function.
The cumulative hazard function.
Freeze conditional age values and other arguments into the object data.
Get the parameters of this model.
Parameters names.
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.
plotThe percent point function.
Random variable sampling.
Set the parameters of this model.
The survival function.
The variance of the distribution.
- cdf(time, a0, *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).
- a0float or np.ndarray
Current ages. If ndarray, shape can only be (m,).
- *args
Any other arguments needed by the model.
- Returns:
- outnp.float64 or np.ndarray
cdf values at each given time(s).
- chf(time, a0, *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).
- a0float or np.ndarray
Current ages. If ndarray, shape can only be (m,).
- *args
Any other arguments needed by the model.
- Returns:
- outnp.float64 or np.ndarray
chf values at each given time(s).
- freeze(a0, *args)[source]#
Freeze conditional age values and other arguments into the object data.
- Parameters:
- a0float or np.ndarray
Conditional age values. It represents ages reached by assets. If ndarray, shape can only be (m,) as only one age per asset can be given
- *argsfloat or np.ndarray
Additional arguments needed by the model.
- Returns:
- FrozenLeftTruncatedModel
- 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, a0, *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).
- a0float or np.ndarray
Current ages. If ndarray, shape can only be (m,).
- *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, a0, *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).
- a0float or np.ndarray
Current ages. If ndarray, shape can only be (m,).
- *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, a0, *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).
- a0float or np.ndarray
Current ages. If ndarray, shape can only be (m,).
- *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, a0, *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.
- a0float or np.ndarray
Current ages. If ndarray, shape can only be (m,).
- *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(a0, *args)[source]#
The mean of the distribution.
- Parameters:
- a0float or np.ndarray
Current ages. If ndarray, shape can only be (m,).
- *args
Any other arguments needed by the model.
- Returns:
- outnp.float64 or np.ndarray
- median(a0, *args)[source]#
The median.
- Parameters:
- a0float or np.ndarray
Current ages. If ndarray, shape can only be (m,).
- *args
Any other arguments needed by the model.
- Returns:
- outnp.float64 or np.ndarray
- moment(n, a0, *args)[source]#
n-th order moment.
- Parameters:
- nint
order of the moment, at least 1.
- a0float or np.ndarray
Current ages. If ndarray, shape can only be (m,).
- *args
Any other arguments needed by the model.
- Returns:
- outnp.float64
- mrl(time, a0, *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).
- a0float or np.ndarray
Current ages. If ndarray, shape can only be (m,).
- *args
Any other arguments needed by the model.
- Returns:
- outnp.float64 or np.ndarray
Function values at each given time(s).
- pdf(time, a0, *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).
- a0float or np.ndarray
Current ages. If ndarray, shape can only be (m,).
- *args
Any other arguments needed by the model.
- Returns:
- outnp.float64 or np.ndarray
pdf values at each given time(s).
- ppf(probability, a0, *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).
- a0float or np.ndarray
Current ages. If ndarray, shape can only be (m,).
- *args
Any other arguments needed by the model.
- Returns:
- outnp.float64 or np.ndarray
ppf values at each given probability value(s).
- rvs(size, a0, *args, seed=None)[source]#
Random variable sampling.
- Parameters:
- sizeint or tuple (m, n) of int
Size of the generated sample.
- a0float or np.ndarray
Current ages. If ndarray, shape can only be (m,).
- *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, a0, *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).
- a0float or np.ndarray
Current ages. If ndarray, shape can only be (m,).
- *args
Any other arguments needed by the model.
- Returns:
- outnp.float64 or np.ndarray
sf values at each given time(s).