NonHomogeneousPoissonProcess#

class relife.stochastic_processes.NonHomogeneousPoissonProcess(lifetime_model)[source]#

Non-homogeneous Poisson process.

Parameters:
lifetime_modelParametricLifetimeModel

Lifetime model defining the process intensity.

Methods

cumulative_intensity

The cumulative intensity function of the process.

fit

Estimate process parameters from recurrent failure data.

freeze

Return a process with additional arguments stored.

get_params

Get the parameters of this model.

intensity

The intensity function of the process.

is_fitted

Whether fitting results are set.

is_parametrized

Whether at least one parameter value is set.

set_params

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.

*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]#

Estimate process parameters from recurrent failure data.

Parameters:
ages_at_events1d array of floats

Ages of each asset when events occurred.

events_assets_idssequence of hashable

Asset ids corresponding to ages_at_events.

first_ages1d array of floats, optional

Asset ages before the observation period. If set, assets_ids is required and must have the same length.

last_ages1d array of floats, optional

Asset ages at the end of the observation period. If set, assets_ids is required and must have the same length.

lifetime_model_argstuple of np.ndarray, optional

Additional arguments needed by the lifetime model. If set, assets_ids is required. For 1d arrays, the size must equal the length of assets_ids. For 2d arrays, the first axis length must equal the length of assets_ids.

assets_idssequence of hashable, optional

Unique asset ids corresponding to values in first_ages, last_ages and/or lifetime_model_args.

Returns:
Self

The current object with estimated parameters set in place.

Examples

Ages of assets AB2 and CX13 at each event.

>>> from relife.lifetime_models import Weibull
>>> from relife.stochastic_processes import NonHomogeneousPoissonProcess
>>> nhpp = NonHomogeneousPoissonProcess(Weibull())
>>> nhpp.fit(
    np.array([11., 13., 21., 25., 27.]),
    ("AB2", "CX13", "AB2", "AB2", "CX13"),
)

With additional information and lifetime model args.

>>> from relife.lifetime_models 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.]),
    lifetime_model_args=(np.array([[1.2, 5.5], [37.2, 22.2]]),)
)
freeze(*args)[source]#

Return a process with additional arguments stored.

Parameters:
*argsfloat or np.ndarray

Additional arguments needed by the model.

Returns:
FrozenNonHomogeneousPoissonProcess
get_params()#

Get the parameters of this model.

Returns:
out1darray of floats

Model parameters.

Notes

If parameter values are not set, they default to np.nan values.

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.

*argsfloat or np.ndarray

Additional arguments needed by the model.

Returns:
np.float64 or np.ndarray

Function values at each given time(s).

is_fitted()#

Whether fitting results are set.

is_parametrized()#

Whether at least one parameter value is set.

set_params(new_params)#

Set the parameters of this model.

Parameters:
new_params1d array-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 can be expressed in the static typesystem.