LeftTruncatedModel#
- class relife.lifetime_model.LeftTruncatedModel(baseline)#
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
Methods
The cumulative distribution function.
The cumulative hazard function.
The hazard function.
Inverse cumulative hazard function.
Inverse survival function.
Lebesgue-Stieltjes integration.
The mean.
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.
- cdf(time, ar, *args)#
The cumulative distribution function.
- Parameters:
- timefloat or np.ndarray
Elapsed time value(s) at which to compute the function. If ndarray, allowed shapes are
()
,(n_values,)
or(n_assets, n_values)
.- 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:
- np.float64 or np.ndarray
Function values at each given time(s).
- chf(time, a0, *args)#
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_values,)
or(n_assets, n_values)
.- 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:
- np.float64 or np.ndarray
Function values at each given time(s).
- hf(time, a0, *args)#
The hazard function.
- Parameters:
- timefloat or np.ndarray
Elapsed time value(s) at which to compute the function. If ndarray, allowed shapes are
()
,(n_values,)
or(n_assets, n_values)
.- 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:
- np.float64 or np.ndarray
Function values at each given time(s).
- ichf(cumulative_hazard_rate, a0, *args)#
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
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:
- np.float64 or np.ndarray
Function values at each given cumulative hazard rate(s).
- isf(probability, a0, *args)#
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
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:
- np.float64 or np.ndarray
Function values at each given probability value(s).
- ls_integrate(func, a, b, a0, *args, deg=10)#
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
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.
- degint, default 10
Degree of the polynomials interpolation
- Returns:
- np.ndarray
Lebesgue-Stieltjes integral of func from a to b.
- mean(a0, *args)#
The mean.
- 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:
- np.float64
The mean value.
- median(a0, *args)#
The median.
- 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:
- np.float64
The median value.
- moment(n, a0, *args)#
n-th order moment
- Parameters:
- norder of the moment, at least 1.
- Returns:
- np.float64
n-th order moment.
- mrl(time, a0, *args)#
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_values,)
or(n_assets, n_values)
.- 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:
- np.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 of the core
Notes
If parameter values are not set, they are encoded as np.nan value.
Parameters can be by manually setting`params` through its setter, fitting the core if fit exists or by specifying all parameters values when the core object is initialized.
- 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, a0, *args)#
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_values,)
or(n_assets, n_values)
.- 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:
- np.float64 or np.ndarray
Function values at each given time(s).
- property plot#
Provides access to plotting functionality for this distribution.
- ppf(probability, a0, *args)#
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
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:
- np.float64 or np.ndarray
Function values at each given probability value(s).
Notes
The
ppf
is the inverse ofcdf()
.
- rvs(size, a0, *args, return_event=False, return_entry=False, seed=None)#
Random variable sampling.
- Parameters:
- sizeint, (int,) or (int, int)
Size of the generated sample. If size is
n
or(n,)
, n samples are generated. If size is(m,n)
, a 2d array of samples is generated.- 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.
- 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, default is None
Random seed used to fix random sampling.
- Returns:
- float, ndarray or tuple of float or ndarray
The sample values. If either
return_event
orrandom_entry
is True, returns a tuple containing the time values followed by event values, entry values or both.
- sf(time, a0, *args)#
The survival function.
- Parameters:
- timefloat or np.ndarray
Elapsed time value(s) at which to compute the function. If ndarray, allowed shapes are
()
,(n_values,)
or(n_assets, n_values)
.- 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:
- np.float64 or np.ndarray
Function values at each given time(s).
- var(a0, *args)#
The variance.
- 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:
- np.float64
The variance value.