NonHomogeneousPoissonProcess#
- class relife.stochastic_process.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.
Generate failure data
The intensity function of the process.
Renewal data sampling.
- 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, assets_ids=None, first_ages=None, last_ages=None, lifetime_model_args=None, **options)[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 ProportionalHazard >>> nhpp = NonHomogeneousPoissonProcess(ProportionalHazard()) >>> 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(size, time_window, *args, seed=None)[source]#
Generate failure data
This function will generate failure data that can be used to fit a non-homogeneous Poisson process.
- Parameters:
- sizeint
The size of the desired sample
- time_windowtuple of two floats
Time window in which failure data are sampled
- seedint, optional
Random seed, by default None.
- Returns:
- A dict of ages_at_events, events_assets_ids, first_ages, last_ages, model_args and assets_ids
- 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).
- 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.
- sample(nb_samples, time_window, *args, seed=None)[source]#
Renewal data sampling.
This function will sample data and encapsulate them in an 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.