def fitbinned(distfn, freq, binedges, start, fixed=None):
 if (not (fixed is None)):
  raise NotImplementedError
 nobs = np.sum(freq)
 lnnobsfact = special.gammaln((nobs + 1))
 def nloglike(params):
  'negative loglikelihood function of binned data\n\n        corresponds to multinomial\n        '
  prob = np.diff(distfn.cdf(binedges, *params))
  return (- (lnnobsfact + np.sum(((freq * np.log(prob)) - special.gammaln((freq + 1))))))
 return optimize.fmin(nloglike, start)

def fitbinned ( distfn , freq , binedges , start , fixed = None ) : if ( not ( fixed is None ) ) : raise NotImplementedError nobs = np . sum ( freq ) lnnobsfact = special . gammaln ( ( nobs + 1 ) ) def nloglike ( params ) : prob = np . diff ( distfn . cdf ( binedges , * params ) ) return ( - ( lnnobsfact + np . sum ( ( ( freq * np . log ( prob ) ) - special . gammaln ( ( freq + 1 ) ) ) ) ) ) return optimize . fmin ( nloglike , start )
estimate parameters of distribution function for binned data using mle parameters distfn : distribution instance needs to have cdf method .