https://raw.githubusercontent.com/MatthewReid854/reliability/master/docs/images/logo.png

Competing_Risks_Model

class reliability.Distributions.Competing_Risks_Model(distributions)

The competing risks model is used to model the effect of multiple risks (expressed as probability distributions) that act on a system over time. The model is obtained using the product of the survival functions:

\(SF_{total} = SF_1 × SF_2 × SF_3 × ... × SF_n\)

The output API is similar to the other probability distributions (Weibull, Normal, etc.) as shown below.

Parameters:distributions (list, array) – a list or array of probability distribution objects used to construct the model
Returns:
  • name (str) – ‘Competing risks’
  • name2 (str) – ‘Competing risks using 3 distributions’. The exact name depends on the number of distributions used
  • mean (float)
  • variance (float)
  • standard_deviation (float)
  • skewness (float)
  • kurtosis (float)
  • excess_kurtosis (float)
  • median (float)
  • mode (float)
  • b5 (float)
  • b95 (float)

Notes

An equivalent form of this model is to sum the hazard or cumulative hazard functions which will give the same result. In this way, we see the CDF, HF, and CHF of the overall model being equal to or higher than any of the constituent distributions. Similarly, the SF of the overall model will always be equal to or lower than any of the constituent distributions. The PDF occurs earlier in time since the earlier risks cause the population to fail sooner leaving less to fail due to the later risks.

This model should be used when a data set has been divided by failure mode and each failure mode has been modelled separately. The competing risks model can then be used to recombine the constituent distributions into a single model. Unlike the mixture model, there are no proportions as the risks are competing to cause failure rather than being mixed.

As this process is multiplicative for the survival function, and may accept many distributions of different types, the mathematical formulation quickly gets complex. For this reason, the algorithm combines the models numerically rather than empirically so there are no simple formulas for many of the descriptive statistics (mean, median, etc.). Also, the accuracy of the model is dependent on xvals. If the xvals array is small (<100 values) then the answer will be ‘blocky’ and inaccurate. The variable xvals is only accepted for PDF, CDF, SF, HF, CHF. The other methods (like random samples) use the default xvals for maximum accuracy. The default number of values generated when xvals is not given is 1000. Consider this carefully when specifying xvals in order to avoid inaccuracies in the results.

CDF(xvals=None, xmin=None, xmax=None, show_plot=True, plot_components=False, **kwargs)

Plots the CDF (cumulative distribution function)

Parameters:
  • show_plot (bool, optional) – True or False. Default = True
  • plot_components (bool) – Option to plot the components of the model. True or False. Default = False.
  • xvals (array, list, optional) – x-values for plotting
  • xmin (int, float, optional) – minimum x-value for plotting
  • xmax (int, float, optional) – maximum x-value for plotting
  • kwargs – Plotting keywords that are passed directly to matplotlib (e.g. color, linestyle)
Returns:

yvals (array, float) – The y-values of the plot

Notes

The plot will be shown if show_plot is True (which it is by default).

If xvals is specified, it will be used. If xvals is not specified but xmin and/or xmax are specified then an array with 200 elements will be created using these limits. If nothing is specified then the range will be based on the distribution’s parameters.

CHF(xvals=None, xmin=None, xmax=None, show_plot=True, plot_components=False, **kwargs)

Plots the CHF (cumulative hazard function)

Parameters:
  • show_plot (bool, optional) – True or False. Default = True
  • plot_components (bool) – Option to plot the components of the model. True or False. Default = False.
  • xvals (array, list, optional) – x-values for plotting
  • xmin (int, float, optional) – minimum x-value for plotting
  • xmax (int, float, optional) – maximum x-value for plotting
  • kwargs – Plotting keywords that are passed directly to matplotlib (e.g. color, linestyle)
Returns:

yvals (array, float) – The y-values of the plot

Notes

The plot will be shown if show_plot is True (which it is by default).

If xvals is specified, it will be used. If xvals is not specified but xmin and/or xmax are specified then an array with 200 elements will be created using these limits. If nothing is specified then the range will be based on the distribution’s parameters.

HF(xvals=None, xmin=None, xmax=None, show_plot=True, plot_components=False, **kwargs)

Plots the HF (hazard function)

Parameters:
  • show_plot (bool, optional) – True or False. Default = True
  • plot_components (bool) – Option to plot the components of the model. True or False. Default = False.
  • xvals (array, list, optional) – x-values for plotting
  • xmin (int, float, optional) – minimum x-value for plotting
  • xmax (int, float, optional) – maximum x-value for plotting
  • kwargs – Plotting keywords that are passed directly to matplotlib (e.g. color, linestyle)
Returns:

yvals (array, float) – The y-values of the plot

Notes

The plot will be shown if show_plot is True (which it is by default).

If xvals is specified, it will be used. If xvals is not specified but xmin and/or xmax are specified then an array with 200 elements will be created using these limits. If nothing is specified then the range will be based on the distribution’s parameters.

PDF(xvals=None, xmin=None, xmax=None, show_plot=True, plot_components=False, **kwargs)

Plots the PDF (probability density function)

Parameters:
  • show_plot (bool, optional) – True or False. Default = True
  • plot_components (bool) – Option to plot the components of the model. True or False. Default = False.
  • xvals (array, list, optional) – x-values for plotting
  • xmin (int, float, optional) – minimum x-value for plotting
  • xmax (int, float, optional) – maximum x-value for plotting
  • kwargs – Plotting keywords that are passed directly to matplotlib (e.g. color, linestyle)
Returns:

yvals (array, float) – The y-values of the plot

Notes

The plot will be shown if show_plot is True (which it is by default).

If xvals is specified, it will be used. If xvals is not specified but xmin and/or xmax are specified then an array with 200 elements will be created using these limits. If nothing is specified then the range will be based on the distribution’s parameters.

SF(xvals=None, xmin=None, xmax=None, show_plot=True, plot_components=False, **kwargs)

Plots the SF (survival function)

Parameters:
  • show_plot (bool, optional) – True or False. Default = True
  • plot_components (bool) – Option to plot the components of the model. True or False. Default = False.
  • xvals (array, list, optional) – x-values for plotting
  • xmin (int, float, optional) – minimum x-value for plotting
  • xmax (int, float, optional) – maximum x-value for plotting
  • kwargs – Plotting keywords that are passed directly to matplotlib (e.g. color, linestyle)
Returns:

yvals (array, float) – The y-values of the plot

Notes

The plot will be shown if show_plot is True (which it is by default).

If xvals is specified, it will be used. If xvals is not specified but xmin and/or xmax are specified then an array with 200 elements will be created using these limits. If nothing is specified then the range will be based on the distribution’s parameters.

inverse_SF(q)

Inverse survival function calculator

Parameters:q (float, list, array) – Quantile to be calculated. Must be between 0 and 1.
Returns:x (float) – The inverse of the SF at q.
mean_residual_life(t)

Mean Residual Life calculator

Parameters:t (int, float) – Time (x-value) at which mean residual life is to be evaluated
Returns:MRL (float) – The mean residual life
plot(xvals=None, xmin=None, xmax=None)

Plots all functions (PDF, CDF, SF, HF, CHF) and descriptive statistics in a single figure

Parameters:
  • xvals (list, array, optional) – x-values for plotting
  • xmin (int, float, optional) – minimum x-value for plotting
  • xmax (int, float, optional) – maximum x-value for plotting
Returns:

None

Notes

The plot will be shown. No need to use plt.show(). If xvals is specified, it will be used. If xvals is not specified but xmin and/or xmax are specified then an array with 200 elements will be created using these limits. If nothing is specified then the range will be based on the distribution’s parameters. No plotting keywords are accepted.

quantile(q)

Quantile calculator

Parameters:q (float, list, array) – Quantile to be calculated. Must be between 0 and 1.
Returns:x (float) – The inverse of the CDF at q. This is the probability that a random variable from the distribution is < q
random_samples(number_of_samples, seed=None)

Draws random samples from the probability distribution

Parameters:
  • number_of_samples (int) – The number of samples to be drawn. Must be greater than 0.
  • seed (int, optional) – The random seed passed to numpy. Default = None
Returns:

samples (array) – The random samples

Notes

This is the same as rvs in scipy.stats

stats()

Descriptive statistics of the probability distribution. These are the same as the statistics shown using .plot() but printed to the console.

Parameters:None
Returns:None