def distfitmc(sample, distr, nrepl=100, distkwds={}):
 arg = distkwds.pop('arg')
 nobs = len(sample)
 res = np.zeros(nrepl)
 for ii in range(nrepl):
  x = distr.rvs(arg, size=nobs, **distkwds)
  res[ii] = distr.fit_fr(x, frozen=[np.nan, 0.0, 1.0])
 return res

def distfitmc ( sample , distr , nrepl = 100 , distkwds = { } ) : arg = distkwds . pop ( 'arg' ) nobs = len ( sample ) res = np . zeros ( nrepl ) for ii in range ( nrepl ) : x = distr . rvs ( arg , size = nobs , ** distkwds ) res [ ii ] = distr . fit_fr ( x , frozen = [ np . nan , 0.0 , 1.0 ] ) return res
run monte carlo for estimation of distribution parameters hard coded: only one shape parameter is allowed and estimated .