Fit_Everything(failures=None, right_censored=None, exclude=None, sort_by='BIC', method='MLE', optimizer=None, print_results=True, show_histogram_plot=True, show_PP_plot=True, show_probability_plot=True, show_best_distribution_probability_plot=True)¶
Fit_Everything This function will fit all available distributions (excluding mixture and competing risks) for the data you enter, which may include right censored data.
Inputs: failures - an array or list of the failure times (this does not need to be sorted). right_censored - an array or list of the right failure times (this does not need to be sorted). sort_by - goodness of fit test to sort results by. Must be ‘BIC’,’AICc’,’AD’, or ‘Log-likelihood’. Default is BIC. method - ‘LS’ (least squares) or ‘MLE’ (maximum likelihood estimation). Default is ‘MLE’. optimizer - ‘L-BFGS-B’, ‘TNC’, or ‘powell’. These are all bound constrained methods. If the bounded method fails, nelder-mead will be used. If nelder-mead fails then the initial guess will be returned with a warning. For more information on optimizers see https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.minimize.html#scipy.optimize.minimize print_results - True/False. Defaults to True. Will show the results of the fitted parameters and the goodness of fittests in a dataframe.
- show_histogram_plot - True/False. Defaults to True. Will show a histogram (scaled to account for censored data) with
- the PDF and CDF of each fitted distribution
- show_PP_plot - True/False. Defaults to True.
- Provides a comparison of parametric vs non-parametric fit using Probability-Probability (PP) plot.
show_probability_plot - True/False. Defaults to True. Provides a probability plot of each of the fitted distributions. show_best_distribution_probability_plot - True/False. Defaults to True. Provides a probability plot in a new figure of the best fitting distribution. exclude - list or array of strings specifying which distributions to exclude. Default is None. Options are Weibull_2P, Weibull_3P, Normal_2P,Gamma_2P, Loglogistic_2P, Gamma_3P, Lognormal_2P, Lognormal_3P, Loglogistic_3P, Gumbel_2P, Exponential_2P, Exponential_1P, Beta_2P
Outputs: results - the dataframe of results. Fitted parameters in this dataframe may be accessed by name. See below example.In displaying these results, the pandas dataframe is designed to use the common greek letter parametrisations rather than the scale, shape, location , threshold parametrisations which can become confusing for some distributions.
best_distribution - a distribution object created based on the parameters of the best fitting distribution best_distribution_name - the name of the best fitting distribution. E.g. ‘Weibull_3P’ parameters and goodness of fit results for each fitted distribution. For example, the Weibull_3P distribution values are:Weibull_3P_alpha Weibull_3P_beta Weibull_3P_gamma Weibull_3P_BIC Weibull_3P_AICc Weibull_3P_AD Weibull_3P_loglik
All parametric models have the number of parameters in the name. For example, Weibull_2P used alpha and beta, whereas Weibull_3P uses alpha, beta, and gamma. This is applied even for Normal_2P for consistency in naming conventions. From the results, the distributions are sorted based on their goodness of fit test results, where the smaller the goodness of fit value, the better the fit of the distribution to the data.
Example Usage: X = [0.95892,1.43249,1.04221,0.67583,3.28411,1.03072,0.05826,1.81387,2.06383,0.59762,5.99005,1.92145,1.35179,0.50391] output = Fit_Everything(X) To extract the parameters of the Weibull distribution from the results dataframe, you may access the parameters by name: print(‘Weibull Alpha =’,output.Weibull_2P_alpha,’
Weibull Beta =’,output.Weibull_2P_beta)