NonHomogeneousPoissonProcess#
- class relife.stochastic_processes.NonHomogeneousPoissonProcess(lifetime_model)[source]#
Non-homogeneous Poisson process.
Methods
The cumulative intensity function of the process.
Estimation of the process parameters from recurrent failure data.
Freeze any arguments required by the process into the object data.
Get the parameters of this model.
Parameters names.
The intensity function of the process.
Renewal data sampling.
Set the parameters of this model.
- cumulative_intensity(time, *args)[source]#
The cumulative intensity function of the process.
- Parameters:
- timefloat or np.ndarray
Elapsed time value(s) at which to compute the function. If ndarray, allowed shapes are
(),(n,)or(m, n).- *argsfloat or np.ndarray
Additional arguments needed by the model.
- Returns:
- np.float64 or np.ndarray
Function values at each given time(s).
- fit(ages_at_events, events_assets_ids, first_ages=None, last_ages=None, lifetime_model_args=None, assets_ids=None, **kwargs)[source]#
Estimation of the process parameters from recurrent failure data.
- Parameters:
- ages_at_events1D array of float
Array of float containing the ages of each asset when the events occured
- events_assets_idssequence of hashable
Sequence object containing the ids of each assets corresponding to each ages.
- first_ages1D array of float, optional
Array of float containing the ages of each asset before observing events. If set,
assets_idsis needed and its length must equal the size offirst_ages.- last_ages1D array of float, optional
Array of float containing the ages of each asset at the end of the observation period. If set,
assets_idsis needed and its length must equal the size oflast_ages.- lifetime_model_argstuple of np.ndarray, optional
Additional arguments needed by the model. If set,
assets_idsis needed. For 1D array, the size must equal the length ofassets_ids. For 2D array (e.g. covar of regression), the length of first axis must equal the length ofassets_ids.- assets_idssequence of hashable, optional
Only needed if either
first_ages,last_agesormodel_argsis filled. It must be a sequence object containing the unique ids corresponding to each values contained infirst_ages,last_agesand/ormodel_args
- Returns:
- Self
The current object with the estimated parameters setted inplace.
Examples
Ages of assets AB2 and CX13 at each event.
>>> from relife.lifetime_model import Weibull >>> from relife.stochastic_process import NonHomogeneousPoissonProcess >>> nhpp = NonHomogeneousPoissonProcess(Weibull()) >>> nhpp.fit( np.array([11., 13., 21., 25., 27.]), ("AB2", "CX13", "AB2", "AB2", "CX13"), )
With additional information and model args (regression of 2 coefficients)
>>> from relife.lifetime_model import ParametricProportionalHazard >>> nhpp = NonHomogeneousPoissonProcess(ParametricProportionalHazard()) >>> nhpp.fit( np.array([11., 13., 21., 25., 27.]), ("AB2", "CX13", "AB2", "AB2", "CX13"), first_ages = np.array([10., 12.]), last_ages = np.array([35., 60.]), model_args = (np.array([[1.2, 5.5], [37.2, 22.2]]),) # 2d array of 2 raws (2 assets) and 2 columns (2 coefficients) )
- freeze(*args)[source]#
Freeze any arguments required by the process into the object data.
- Parameters:
- *argsfloat or np.ndarray
Additional arguments needed by the model.
- Returns:
- FrozenParametricModel
- generate_failure_data(nb_samples, time_window, *args, seed=None)[source]#
Warning
Not implemented yet
- 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.
- intensity(time, *args)[source]#
The intensity function of the process.
- Parameters:
- timefloat or np.ndarray
Elapsed time value(s) at which to compute the function. If ndarray, allowed shapes are
(),(n,)or(m, n).- *argsfloat or np.ndarray
Additional arguments needed by the model.
- Returns:
- np.float64 or np.ndarray
Function values at each given time(s).
- sample(nb_samples, time_window, *args, a0=None, ar=None, seed=None)[source]#
Renewal data sampling.
Samples data and encapsulates them in a StochasticSampleMapping object.
- Parameters:
- nb_samplesint
The number of samples
- time_windowtuple of two floats
Time window in which data are sampled
- *argsfloat or np.ndarray
Additional arguments needed by the model.
- seedint, optional
Random seed, by default None.
- 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.