LogLogistic#
- final class relife.lifetime_model.LogLogistic(shape=None, rate=None)[source]#
Log-logistic probability distribution.
The Log-logistic distribution is defined as a 2-parameter distribution \((c, \lambda)\). The probability density function is:
\[f(t) = \frac{c \lambda^c t^{c-1}}{(1+(\lambda t)^{c})^2}\]where:
\(c > 0\), the shape parameter,
\(\lambda > 0\), the rate parameter,
\(t\geq 0\), the operating time, age, cycles, etc.
- Parameters:
- shapefloat, default is None
Shape parameter.
- ratefloat, default is None
Rate parameter.
- Attributes:
- fitting_resultsFittingResults, default is None
An object containing fitting results (AIC, BIC, etc.). If the model is not fitted, the value is None.
nb_paramsNumber of parameters.
paramsParameters values.
params_namesParameters names.
plotProvides access to plotting functionnalities
shapeReturns the shape value.
rateReturns the rate value.
Methods
The cumulative density function.
The cumulative hazard function.
The derivate of the hazard function.
Estimation of the distribution parameters from lifetime data.
Estimation of the distribution parameters from interval censored lifetime data.
Gets the inital parameters values used in before fitting.
The hazard function.
Inverse cumulative hazard function.
The inverse survival function.
The jacobian of the cumulative density function.
The jacobian of the cumulative hazard function.
The jacobian of the hazard function.
The jacobian of the probability density function.
The jacobian of the 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)#
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).
- Returns:
- outnp.float64 or np.ndarray
cdf values at each given time(s).
- chf(time)[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).
- Returns:
- outnp.float64 or np.ndarray
chf values at each given time(s).
- dhf(time)[source]#
The derivate of 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).
- Returns:
- outnp.float64 or np.ndarray
Function values at each given time(s).
- fit(time, model_args=None, event=None, entry=None, optimizer_options=None)#
Estimation of the distribution parameters from lifetime data.
- Parameters:
- time1d array
Observed lifetime values.
- model_argsany ndarray or tuple of ndarray, default is None
Any additional arguments required by the model.
- event1d array of bool, default is None
Boolean indicators tagging lifetime values as right censored or complete.
- entry1d array, default is None
Left truncations applied to lifetime values.
- optimizer_optionsdict, default is None
- Extra arguments used by scipy.minimize. Default values are:
method : “L-BFGS-B”
contraints : ()
tol : None
callback : None
options : None
bounds : self.params_bounds
x0 : self.init_params
- Returns:
- outthe object instance
The estimated parameters are setted inplace.
- fit_from_interval_censored_lifetimes(time_inf, time_sup, model_args=None, entry=None, optimizer_options=None)#
Estimation of the distribution parameters from interval censored lifetime data.
- Parameters:
- time_inf1d array
Observed lifetime lower bounds.
- time_sup1d array
Observed lifetime upper bounds.
- model_argsany ndarray or tuple of ndarray, default is None
Any additional arguments required by the model.
- entry1d array, default is None
Left truncations applied to lifetime values.
- optimizer_optionsdict, default is None
- Extra arguments used by scipy.minimize. Default values are:
method : “L-BFGS-B”
contraints : ()
tol : None
callback : None
options : None
bounds : self.params_bounds
x0 : self.init_params
- Returns:
- outthe object instance
The estimated parameters are setted inplace.
Notes
Where time_inf == time_sup, lifetimes are complete.
- get_initial_params(time, event=None, model_args=None)#
Gets the inital parameters values used in before fitting.
- Parameters:
- time1d array
Observed lifetime values.
- event1d array of bool, default is None
Boolean indicators tagging lifetime values as right censored or complete. If it is not None, it will be used to select only complete lifetimes.
- model_argsany ndarray or tuple of ndarray, default is None
Any additional arguments required by the model.
- Returns:
- out1d array of float
- hf(time)[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).
- Returns:
- outnp.float64 or np.ndarray
hf values at each given time(s).
- ichf(cumulative_hazard_rate)[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).
- Returns:
- outnp.float64 or np.ndarray
ichf values at each given cumulative hazard rate(s).
- isf(probability)#
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).
- Returns:
- outnp.float64 or np.ndarray
isf values at each given probability value(s).
- jac_cdf(time)#
The jacobian of 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).
- Returns:
- outnp.float64 or np.ndarray
The derivatives with respect to each parameter. If the result is an np.ndarray, the first dimension holds the number of parameters.
- jac_chf(time)[source]#
The jacobian of 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).
- Returns:
- outnp.float64 or np.ndarray
The derivatives with respect to each parameter. If the result is an np.ndarray, the first dimension holds the number of parameters.
- jac_hf(time)[source]#
The jacobian of 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).
- Returns:
- outnp.float64 or np.ndarray
The derivatives with respect to each parameter. If the result is an np.ndarray, the first dimension holds the number of parameters.
- jac_pdf(time)#
The jacobian of 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).
- Returns:
- outnp.float64 or np.ndarray
The derivatives with respect to each parameter. If the result is an np.ndarray, the first dimension holds the number of parameters.
- jac_sf(time)#
The jacobian of 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).
- Returns:
- outnp.float64 or np.ndarray
The derivatives with respect to each parameter. If the result is an np.ndarray, the first dimension holds the number of parameters.
- ls_integrate(func, a, b, *, 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.
- degint, default 10
Degree of the polynomials interpolation.
- Returns:
- outnp.ndarray
Lebesgue-Stieltjes integral of func from a to b.
- median()#
The median.
- Returns:
- outnp.float64
- moment(n)#
n-th order moment.
- Parameters:
- nint
order of the moment, at least 1.
- Returns:
- outnp.float64
- mrl(time)[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).
- 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_bounds#
Parameters bounds
- 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)#
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).
- Returns:
- outnp.float64 or np.ndarray
pdf values at each given time(s).
- property plot#
Provides access to plotting functionnalities
- ppf(probability)#
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).
- Returns:
- outnp.float64 or np.ndarray
ppf values at each given probability value(s).
- property rate#
Returns the rate value.
- Returns:
- out: float
- rvs(size, *, return_event=False, return_entry=False, seed=None)#
Random variable sampling.
- Parameters:
- sizeint or tuple (m, n) of int
Size of the generated sample.
- 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:
- outfloat, ndarray or tuple of float or ndarray
The sample values. If either return_event or return_entry is True, returns a tuple containing the time values followed by event values, entry values or both.
- sf(time)#
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).
- Returns:
- outnp.float64 or np.ndarray
sf values at each given time(s).
- property shape#
Returns the shape value.
- Returns:
- out: float