
Normal_Distribution
- class reliability.Distributions.Normal_Distribution(mu=None, sigma=None, **kwargs)
Normal probability distribution. Creates a probability distribution object.
- Parameters:
mu (float, int) – Location parameter
sigma (float, int) – Scale parameter. Must be > 0
- Returns:
name (str) – ‘Normal’
name2 (‘str) – ‘Normal_2P’
param_title_long (str) – ‘Normal Distribution (μ=5,σ=2)’
param_title (str) – ‘μ=5,σ=2’
parameters (list) – [mu,sigma]
mu (float)
sigma (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:
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
show_plot (bool, optional) – True or False. Default = True
plot_CI (bool, optional) – True or False. Default = True. Only used if the distribution object was created by Fitters.
CI_type (str, optional) – Must be either “time”, “reliability”, or “none”. Default is “time”. Only used if the distribution object was created by Fitters.
CI (float, optional) – The confidence interval between 0 and 1. Only used if the distribution object was created by Fitters.
CI_y (list, array, optional) – The confidence interval y-values to trace. Only used if the distribution object was created by Fitters and CI_type=’time’.
CI_x (list, array, optional) – The confidence interval x-values to trace. Only used if the distribution object was created by Fitters and CI_type=’reliability’.
kwargs – Plotting keywords that are passed directly to matplotlib (e.g. color, linestyle)
- Returns:
yvals (array, float) – The y-values 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 y-values from the distribution at CI_x. If CI_y is specified, the point estimate is the x-values 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:
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
show_plot (bool, optional) – True or False. Default = True
plot_CI (bool, optional) – True or False. Default = True. Only used if the distribution object was created by Fitters.
CI_type (str, optional) – Must be either “time”, “reliability”, or “none”. Default is “time”. Only used if the distribution object was created by Fitters.
CI (float, optional) – The confidence interval between 0 and 1. Only used if the distribution object was created by Fitters.
CI_y (list, array, optional) – The confidence interval y-values to trace. Only used if the distribution object was created by Fitters and CI_type=’time’.
CI_x (list, array, optional) – The confidence interval x-values to trace. Only used if the distribution object was created by Fitters and CI_type=’reliability’.
kwargs – Plotting keywords that are passed directly to matplotlib (e.g. color, linestyle)
- Returns:
yvals (array, float) – The y-values 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 y-values from the distribution at CI_x. If CI_y is specified, the point estimate is the x-values 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) – 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, plot_CI=True, CI_type=None, CI=None, CI_y=None, CI_x=None, **kwargs)
Plots the SF (survival function)
- Parameters:
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
show_plot (bool, optional) – True or False. Default = True
plot_CI (bool, optional) – True or False. Default = True. Only used if the distribution object was created by Fitters.
CI_type (str, optional) – Must be either “time”, “reliability”, or “none”. Default is “time”. Only used if the distribution object was created by Fitters.
CI (float, optional) – The confidence interval between 0 and 1. Only used if the distribution object was created by Fitters.
CI_y (list, array, optional) – The confidence interval y-values to trace. Only used if the distribution object was created by Fitters and CI_type=’time’.
CI_x (list, array, optional) – The confidence interval x-values to trace. Only used if the distribution object was created by Fitters and CI_type=’reliability’.
kwargs – Plotting keywords that are passed directly to matplotlib (e.g. color, linestyle)
- Returns:
yvals (array, float) – The y-values 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 y-values from the distribution at CI_x. If CI_y is specified, the point estimate is the x-values 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, array) – 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, array) – 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