rvsmin = rvs.min()

def pareto_ks(loc, rvs):
    est = stats.pareto.fit_fr(rvs, 1.0, frozen=[np.nan, loc, np.nan])
args = est[0], loc, est[1]
return stats.kstest(rvs, 'pareto', args)[0]
locest = optimize.fmin(pareto_ks, rvsmin * 0.7, (rvs,))
est = stats.pareto.fit_fr(rvs, 1.0, frozen=[np.nan, locest, np.nan])
args = est[0], locest[0], est[1]
print('estimate')
print(args)
print('kstest')
print(stats.kstest(rvs, 'pareto', args))
print('estimation error', args - np.array(true))
Fitting a pareto distribution with (python) Scipy