RenewalProcess#

class relife.stochastic_processes.RenewalProcess(lifetime_model, first_lifetime_model=None)[source]#

Renewal process.

Parameters:
lifetime_modelany lifetime distribution or frozen lifetime model

A lifetime model representing the durations between events.

first_lifetime_modelany lifetime distribution or frozen lifetime model, optional

A lifetime model for the first renewal (delayed renewal process). It is lifetime_model by default.

Attributes:
lifetime_modelany lifetime distribution or frozen lifetime model

A lifetime model representing the durations between events.

first_lifetime_modelany lifetime distribution or frozen lifetime model, optional

A lifetime model for the first renewal (delayed renewal process). It is lifetime_model by default

Methods

expected_number_of_events

The expected number of observed events.

expected_number_of_preventive_renewals

The expected number of preventive renewals.

generate_failure_data

Generate lifetime data

get_params

Get the parameters of this model.

get_params_names

Parameters names.

renewal_density

The renewal density.

renewal_function

The renewal function.

sample

Renewal data sampling.

set_params

Set the parameters of this model.

expected_number_of_events(tf, nb_steps, a0=None, ar=None)[source]#

The expected number of observed events.

Here, events are assets failures, i.e. only the assets failures are counted (not the preventive replacements at ar).

The function is noted \(m_e\) and computed by solving :

\[m_e(t) = F(\text{min}(t,~a_r)) + \int_0^{t}m_e(t-x)dF_{a_r}(x)\]

where:

  • \(F\) is the cumulative distribution function of the time to failure \(X\).

  • \(F_{a_r}\) is the cumulative distribution of \(T = \text{min}(X,~a_r)\).

If a0 or first_lifetime_model is given, instead, we compute \(m_e^{\text{delayed}}\) by solving:

\[m_e^{\text{delayed}}(t) = F_1(\text{min}(t,~a_r)) + \int_0^{t}m_e(t-x)dF_{1_{a_r}}(x)\]

where:

  • \(F_1\) is the cumulative distribution function of the first time to failure \(X_1\).

  • \(F_{1_{a_r}}\) is the cumulative distribution of \(T_1 = \text{min}(X_1,~a_r)\).

Note

If ar is None, \(a_r = \infty\).

This function is complementary to expected_number_of_preventive_renewals() i.e. \(m(t) = m_e(t) + m_p(t)\).

See also renewal_function().

Parameters:
tffloat

The final time.

nb_stepsint

The number of steps used to discretized the time.

a0float or np.ndarray, optional

Initial ages of the assets.

arfloat or np.ndarray, optional

Preventive ages of replacements.

Returns:
outtuple of two ndarrays

A timeline and the corresponding values.

Notes

Preventive replacements are not considered as events. Only renewals are. Thus, there are not counted.

expected_number_of_preventive_renewals(tf, nb_steps, ar, a0=None)[source]#

The expected number of preventive renewals.

The function is noted \(m_p\) and computed by solving :

\[m_p(t) = \mathbb{1}_{t > a_r} \cdot (1 - F(a_r)) + \int_0^{t}m_p(t-x)dF_{a_r}(x)\]

where:

  • \(F\) is the cumulative distribution function of the time to failure \(X\).

  • \(F_{a_r}\) is the cumulative distribution of \(T = \text{min}(X,~a_r)\).

If a0 or first_lifetime_model is given, instead, we compute \(m_p^{\text{delayed}}\) by solving:

\[m_p^{\text{delayed}}(t) = \mathbb{1}_{t > a_r} \cdot (1 - F_1(a_r)) + \int_0^{t}m_p(t-x)dF_{1_{a_r}}(x)\]

where:

  • \(F_1\) is the cumulative distribution function of the first time to failure \(X_1\).

  • \(F_{1_{a_r}}\) is the cumulative distribution of \(T_1 = \text{min}(X_1,~a_r)\).

Note

If ar is None, \(a_r = \infty\).

This function is complementary to expected_number_of_events() i.e. \(m(t) = m_e(t) + m_p(t)\).

See also renewal_function().

Parameters:
tffloat

The final time.

nb_stepsint

The number of steps used to discretized the time.

arfloat or np.ndarray

Preventive ages of replacements.

a0float or np.ndarray, optional

Initial ages of the assets.

Returns:
outtuple of two ndarrays

A timeline and the corresponding values.

generate_failure_data(nb_samples, time_window, a0=None, ar=None, seed=None)[source]#

Generate lifetime data

This function will generate lifetime data that can be used to fit a lifetime model.

Parameters:
nb_samplesint

The size of the desired sample

time_windowtuple of two floats

Time window in which data are sampled

a0float or np.ndarray, optional

Initial ages of the assets.

arfloat or np.ndarray, optional

Preventive ages of replacements.

seedint, optional

Random seed, by default None.

Returns:
A dict of time, event, entry and args (covariates)
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.

renewal_density(tf, nb_steps, a0=None, ar=None)[source]#

The renewal density.

It is the derivative \(\omega\) of the renewal function \(m\). See the renewal_function().

\[\omega(t) = m'(t) = f_1(t) + \int_0^t \omega(t-x) \mathrm{d}F(x)\]

where:

  • \(F\) is the cumulative distribution function of the time to failure \(X\).

  • \(f_1\) is the probability density function of the first time to failure \(X_1\).

If ar is given, \(F\) becomes \(F_{a_r}\) defined by \(T = \text{min}(X,~a_r) \sim F_{a_r}\). The same applies for \(X_1\). \(F_1\) becomes \(F_{1_{a_r}}\) defined by \(T_1 = \text{min}(X_1,~a_r) \sim F_{1_{a_r}}\).

If a0 is given, \(F_1\) becomes \(\mathbb{P}(X \leq t |~ X > a_0)\).

Parameters:
tffloat

The final time.

nb_stepsint

The number of steps used to discretized the time.

a0float or np.ndarray, optional

Initial ages of the assets.

arfloat or np.ndarray, optional

Preventive ages of replacements.

Returns:
tuple of two ndarrays

A tuple containing the timeline and the computed values.

References

[1]

Rausand, M., Barros, A., & Hoyland, A. (2020). System Reliability Theory: Models, Statistical Methods, and Applications. John Wiley & Sons.

renewal_function(tf, nb_steps, a0=None, ar=None)[source]#

The renewal function.

It gives the expected total number of renewals \(m\). It is computed by solving the renewal equation:

\[m(t) = F_1(t) + \int_0^t m(t-x) \mathrm{d}F(x)\]

where:

  • \(F\) is the cumulative distribution function of the time to failure \(X\).

  • \(F_1\) is the cumulative distribution function of the first time to failure \(X_1\).

If ar is given, \(F\) becomes \(F_{a_r}\) defined by \(T = \text{min}(X,~a_r) \sim F_{a_r}\). The same applies for \(X_1\). \(F_1\) becomes \(F_{1_{a_r}}\) defined by \(T_1 = \text{min}(X_1,~a_r) \sim F_{a_r}\).

If a0 is given, \(F_1\) becomes \(\mathbb{P}(X \leq t |~ X > a_0)\).

Parameters:
tffloat

The final time.

nb_stepsint

The number of steps used to discretized the time.

a0float or np.ndarray, optional

Initial ages of the assets.

arfloat or np.ndarray, optional

Preventive ages of replacements.

Returns:
outtuple of two ndarrays

A timeline and the corresponding values.

References

[1]

Rausand, M., Barros, A., & Hoyland, A. (2020). System Reliability Theory: Models, Statistical Methods, and Applications. John Wiley & Sons.

sample(nb_samples, time_window, a0=None, ar=None, seed=None)[source]#

Renewal data sampling.

This function will sample data and encapsulate them in an object.

Parameters:
nb_samplesint

The size of the desired sample

time_windowtuple of two floats

Time window in which data are sampled

a0float or np.ndarray, optional

Initial ages of the assets.

arfloat or np.ndarray, optional

Preventive ages of replacements.

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.