Gamma_Distribution¶

class
reliability.Distributions.
Gamma_Distribution
(alpha=None, beta=None, gamma=0, **kwargs)¶ Gamma probability distribution. Creates a probability distribution object.
Parameters:  alpha (float, int) – Scale parameter. Must be > 0
 beta (float, int) – Shape parameter. Must be > 0
 gamma (float, int, optional) – threshold (offset) parameter. Must be >= 0. Default = 0
Returns:  name (str) – ‘Gamma’
 name2 (‘str) – ‘Gamma_2P’ or ‘Gamma_3P’ depending on the value of the gamma parameter
 param_title_long (str) – ‘Gamma Distribution (α=5,β=2)’
 param_title (str) – ‘α=5,β=2’
 parameters (list) – [alpha,beta,gamma]
 alpha (float)
 beta (float)
 gamma (float)
 mean (float)
 variance (float)
 standard_deviation (float)
 skewness (float)
 kurtosis (float)
 excess_kurtosis (float)
 median (float)
 mode (float)
 b5 (float)
 b95 (float)
Notes
kwargs are used internally to generate the confidence intervals

CDF
(xvals=None, xmin=None, xmax=None, show_plot=True, plot_CI=True, CI_type=None, CI=None, CI_y=None, CI_x=None, **kwargs)¶ Plots the CDF (cumulative distribution function)
Parameters:  show_plot (bool, optional) – True or False. Default = True
 xvals (array, list, optional) – xvalues for plotting
 xmin (int, float, optional) – minimum xvalue for plotting
 xmax (int, float, optional) – maximum xvalue for plotting
 kwargs – Plotting keywords that are passed directly to matplotlib (e.g. color, linestyle)
Returns:  yvals (array, float) – The yvalues of the plot. Only returned if CI_x and CI_y are not specified.
 lower_estimate, point_estimate, upper_estimate (tuple) – A tuple of arrays or floats of the confidence interval estimates based on CI_x or CI_y. Only returned if CI_x or CI_y is specified and the confidence intervals are available. If CI_x is specified, the point estimate is the yvalues from the distribution at CI_x. If CI_y is specified, the point estimate is the xvalues from the distribution at CI_y.
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_CI=True, CI_type=None, CI=None, CI_y=None, CI_x=None, **kwargs)¶ Plots the CHF (cumulative hazard function)
Parameters:  show_plot (bool, optional) – True or False. Default = True
 xvals (array, list, optional) – xvalues for plotting
 xmin (int, float, optional) – minimum xvalue for plotting
 xmax (int, float, optional) – maximum xvalue for plotting
 kwargs – Plotting keywords that are passed directly to matplotlib (e.g. color, linestyle)
Returns:  yvals (array, float) – The yvalues of the plot. Only returned if CI_x and CI_y are not specified.
 lower_estimate, point_estimate, upper_estimate (tuple) – A tuple of arrays or floats of the confidence interval estimates based on CI_x or CI_y. Only returned if CI_x or CI_y is specified and the confidence intervals are available. If CI_x is specified, the point estimate is the yvalues from the distribution at CI_x. If CI_y is specified, the point estimate is the xvalues from the distribution at CI_y.
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) – xvalues for plotting
 xmin (int, float, optional) – minimum xvalue for plotting
 xmax (int, float, optional) – maximum xvalue for plotting
 kwargs – Plotting keywords that are passed directly to matplotlib (e.g. color, linestyle)
Returns: yvals (array, float) – The yvalues 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) – xvalues for plotting
 xmin (int, float, optional) – minimum xvalue for plotting
 xmax (int, float, optional) – maximum xvalue for plotting
 kwargs – Plotting keywords that are passed directly to matplotlib (e.g. color, linestyle)
Returns: yvals (array, float) – The yvalues 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_CI=True, CI_type=None, CI=None, CI_y=None, CI_x=None, **kwargs)¶ Plots the SF (survival function)
Parameters:  show_plot (bool, optional) – True or False. Default = True
 xvals (array, list, optional) – xvalues for plotting
 xmin (int, float, optional) – minimum xvalue for plotting
 xmax (int, float, optional) – maximum xvalue for plotting
 kwargs – Plotting keywords that are passed directly to matplotlib (e.g. color, linestyle)
Returns:  yvals (array, float) – The yvalues of the plot. Only returned if CI_x and CI_y are not specified.
 lower_estimate, point_estimate, upper_estimate (tuple) – A tuple of arrays or floats of the confidence interval estimates based on CI_x or CI_y. Only returned if CI_x or CI_y is specified and the confidence intervals are available. If CI_x is specified, the point estimate is the yvalues from the distribution at CI_x. If CI_y is specified, the point estimate is the xvalues from the distribution at CI_y.
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 (xvalue) 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) – xvalues for plotting
 xmin (int, float, optional) – minimum xvalue for plotting
 xmax (int, float, optional) – maximum xvalue 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