def findBestDistribution(data, disttype='<STR_LIT>'):
if disttype != '<STR_LIT>':<EOL><INDENT>raise NotImplemented()<EOL><DEDENT>distributions = [st.alpha, st.anglit, st.arcsine,<EOL>st.beta, st.betaprime, st.bradford,<EOL>st.burr, st.cauchy, st.chi,<EOL>st.chi2, st.cosine, st.dgamma,<EOL>st.dweibull, st.erlang, st.expon,<EOL>st.exponweib, st.exponpow, st.f,<EOL>st.fatiguelife,<EOL>st.fisk, st.foldcauchy, st.foldnorm,<EOL>st.frechet_r, st.frechet_l, st.genlogistic, st.genpareto,<EOL>st.genexpon, st.genextreme, st.gausshyper,<EOL>st.gamma, st.gengamma, st.genhalflogistic,<EOL>st.gilbrat, st.gompertz, st.gumbel_r,<EOL>st.gumbel_l, st.halfcauchy, st.halflogistic,<EOL>st.halfnorm, st.hypsecant, st.invgamma,<EOL>st.invgauss, st.invweibull, st.johnsonsb,<EOL>st.johnsonsu, st.ksone, st.kstwobign,<EOL>st.laplace, st.logistic, st.loggamma,<EOL>st.loglaplace, st.lognorm, st.lomax,<EOL>st.maxwell, st.mielke, st.nakagami,<EOL>st.ncx2, st.ncf, st.nct,<EOL>st.norm, st.pareto, st.pearson3,<EOL>st.powerlaw, st.powerlognorm,<EOL>st.powernorm, st.rdist, st.reciprocal,<EOL>st.rayleigh, st.rice, st.recipinvgauss,<EOL>st.semicircular, st.t, st.triang,<EOL>st.truncexpon, st.truncnorm, st.tukeylambda,<EOL>st.uniform, st.vonmises, st.wald,<EOL>st.weibull_min, st.weibull_max, st.wrapcauchy]<EOL>mles = []<EOL>pars_l = []<EOL>valid_dist = []<EOL>with warnings.catch_warnings():<EOL><INDENT>warnings.filterwarnings('<STR_LIT:ignore>')<EOL>for distribution in distributions:<EOL><INDENT>pars = distribution.fit(data)<EOL>mle = distribution.nnlf(pars, data)<EOL>if np.isfinite(mle):<EOL><INDENT>valid_dist.append(distribution)<EOL>mles.append(abs(mle))<EOL>pars_l.append(pars)<EOL><DEDENT><DEDENT><DEDENT>best_fit = sorted(zip(valid_dist, mles, pars_l), key=lambda d: d[<NUM_LIT:1>])[<NUM_LIT:0>]<EOL>print(<EOL>'<STR_LIT>'.format(<EOL>best_fit[<NUM_LIT:0>].name,<EOL>best_fit[<NUM_LIT:1>]))<EOL>print(pars_l)<EOL>return best_fit[<NUM_LIT:0>], best_fit[<NUM_LIT:2>]<EOL>
find best statistical distribution,see:
http://docs.scipy.org/doc/scipy-0.14.0/reference/stats.html

currently only continuous distributions embedded

returns scipy.stats[DIST], fitparams