def fit_gamma(samples): samples = [double(n) for n in samples if n > 0]#because rpy does not like longs! r.library('MASS') f = r.fitdistr(samples,'gamma') shap,rat = f['estimate']['shape'],f['estimate']['rate'] qp = r.qgamma(r.ppoints(samples),shape=shap,rate=rat) return qp,shape,rat
def fit_weibull(samples): #samples = [double(n) for n in samples if n > 0]#because rpy does not like longs! r.library('MASS') f = r.fitdistr(samples,'weibull') sc,sh = f['estimate']['scale'],f['estimate']['shape'] qp = r.qweibull(r.ppoints(samples),scale=sc,shape=sh) return qp,sc,sh
def fit_weibull(samples): #samples = [double(n) for n in samples if n > 0]#because rpy does not like longs! r.library('MASS') f = r.fitdistr(samples, 'weibull') sc, sh = f['estimate']['scale'], f['estimate']['shape'] qp = r.qweibull(r.ppoints(samples), scale=sc, shape=sh) return qp, sc, sh
def fit_exponential(samples): samples = [float(n) for n in samples]#because rpy does not like longs! r.library('MASS') f = r.fitdistr(samples,'exponential') rat = f['estimate']['rate'] qp = r.qexp(r.ppoints(samples),rate=rat) return qp, rat
def fit_exponential(samples): samples = [float(n) for n in samples] #because rpy does not like longs! r.library('MASS') f = r.fitdistr(samples, 'exponential') rat = f['estimate']['rate'] qp = r.qexp(r.ppoints(samples), rate=rat) return qp, rat
def fit_gamma(samples): samples = [double(n) for n in samples if n > 0] #because rpy does not like longs! r.library('MASS') f = r.fitdistr(samples, 'gamma') shap, rat = f['estimate']['shape'], f['estimate']['rate'] qp = r.qgamma(r.ppoints(samples), shape=shap, rate=rat) return qp, shape, rat
def fit_nbinom(samples): r.library('MASS') f = r.fitdistr(samples,'negative binomial') s,m = f['estimate']['size'],f['estimate']['mu'] qp = r.qnbinom(r.ppoints(samples),size=s,mu=m) return qp,s,m
def fit_poisson(samples): r.library('MASS') f = r.fitdistr(samples,'poisson') l = f['estimate']['lambda'] #predicted mean qp = r.qpois(r.ppoints(samples),l) return qp,l
def fit_poisson(samples): r.library('MASS') f = r.fitdistr(samples, 'poisson') l = f['estimate']['lambda'] #predicted mean qp = r.qpois(r.ppoints(samples), l) return qp, l
def fit_nbinom(samples): r.library('MASS') f = r.fitdistr(samples, 'negative binomial') s, m = f['estimate']['size'], f['estimate']['mu'] qp = r.qnbinom(r.ppoints(samples), size=s, mu=m) return qp, s, m