DSZI_Model
- class reliability.Distributions.DSZI_Model(distribution, DS=None, ZI=None)
Defective Subpopulation Zero Inflated Model. This model should be used when there are failures at t=0 (“dead on arrival”) creating a zero inflated (ZI) distribution and/or many right censored failures creating a defective subpopulation (DS) model. The parameters DS and ZI represent the maximum and minimum of the CDF respectively. Their default values are 1 and 0 which is equivalent to a non-DS and non-ZI model. Leaving one as the default and specifying the other can be used to create a DS or ZI model, while specifying both parameters creates a DSZI model.
The output API is similar to the other probability distributions (Weibull, Normal, etc.) as shown below.
- Parameters:
distribution (object) – A probability distribution object representing the base distribution to which the DS and ZI transformations are made.
DS (float, optional) – The defective subpopulation fraction. Must be between 0 and 1. Must be greater than ZI. This is the maximum of the CDF. Default is 1 which is equivalent to a non-DS CDF (ie. everything fails eventually).
ZI (float, optional) – The zero inflated fraction. Must be between 0 and 1. Must be less than DS. This is the minimum of the CDF. Default is 0 which is equivalent to a non-ZI CDF (ie. no failures at t=0).
- Returns:
DS (float)
ZI (float)
name (str) – ‘DSZI’
name2 (str) – ‘Defective Subpopulation Zero Inflated Weibull’. Exact string depends on the values of DS and ZI, and the type of base distribution.
mean (float)
variance (float)
standard_deviation (float)
skewness (float)
kurtosis (float)
excess_kurtosis (float)
median (float)
mode (float)
b5 (float)
b95 (float)
Notes
DS and ZI are optional but at least one of them must be specified. Leaving them both unspecified is equivalent to the base distribution specified in the “distribution” parameter.
- CDF(xvals=None, xmin=None, xmax=None, show_plot=True, **kwargs)
Plots the CDF (cumulative distribution function)
- Parameters:
show_plot (bool, optional) – True or False. Default = True
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, **kwargs)
Plots the CHF (cumulative hazard function)
- Parameters:
show_plot (bool, optional) – True or False. Default = True
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, **kwargs)
Plots the HF (hazard function)
- Parameters:
show_plot (bool, optional) – True or False. Default = True
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, **kwargs)
Plots the PDF (probability density function)
- Parameters:
show_plot (bool, optional) – True or False. Default = True
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, **kwargs)
Plots the SF (survival function)
- Parameters:
show_plot (bool, optional) – True or False. Default = True
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.
Notes
If DS < 1 the MRL will return np.inf
- 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 ZI and DS. If q < ZI or q > DS then a ValueError will be raised.
- 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, right_censored_time=None, 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.
right_censored_time (float) – The time to use as the right censored value. Only required if DS is not 1. The right_censored_time can be thought of as the end of the observation period.
seed (int, optional) – The random seed passed to numpy. Default = None
- Returns:
failures, right_censored (array, array) – failures is an array of the random samples of the failure times. right_censored is an array of the right censored random samples. failures will contain zeros is ZI > 0. right_censored will be empty if DS = 1, otherwise all of the All the right_censored samples will be equal to the parameter right_censored_time.
Notes
If any of the failure times exceed the right_censored_time, these failures will be converted to right_censored_time and moved into the right_censored array. A warning will be printed if this occurs. To prevent this from occurring, select a higher right_censored_time.
- 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