solution = solver.Solution() return solution, stepmon if __name__ == '__main__': target = [1., 45., -10., 20., 1., 0.1, 120.] from mystic.models.lorentzian import gendata, histogram npts = 4000 binwidth = 0.1 N = npts * binwidth xmin, xmax = 0.0, 3.0 pdf = F(target) print("pdf(1): %s" % pdf(1)) data = gendata(target, xmin, xmax, npts) plt.plot(data[1:int(N)], 0 * data[1:int(N)], 'k.') plt.title('Samples drawn from density to be estimated.') try: show() except ImportError: plt.show() plt.clf() binsc, histo = histogram(data, binwidth, xmin, xmax) print("binsc: %s" % binsc) print("count: %s" % histo) print("ncount: %s" % (histo // N)) print("exact : %s" % pdf(binsc)) print("now with DE...")
solution = solver.Solution() return solution, stepmon if __name__ == '__main__': #NOTE: we will calculate the norm, not solve for it as a parameter target = [1., 45., -10., 20., 1., 0.1, 1.0] # norm set to 1.0 from mystic.models.lorentzian import gendata, histogram npts = 4000; binwidth = 0.1 N = npts * binwidth xmin, xmax = 0.0, 3.0 pdf = F(target) # normalized print "pdf(1): ", pdf(1) data = gendata(target, xmin, xmax, npts) # data is 'unnormalized' #pylab.plot(data[1:N],0*data[1:N],'k.') #pylab.title('Samples drawn from density to be estimated.') #show() #pylab.clf() binsc, histo = histogram(data, binwidth, xmin,xmax) print "binsc: ", binsc print "count: ", histo print "ncount: ", histo/N print "exact : ", pdf(binsc) print "now with DE..." from mystic.forward_model import CostFactory CF = CostFactory() CF.addModel(F, 'lorentz', ND)
sigint_callback = plot_sol(solver)) solution = solver.Solution() return solution, stepmon if __name__ == '__main__': target = [1., 45., -10., 20., 1., 0.1, 120.] from mystic.models.lorentzian import gendata, histogram npts = 4000; binwidth = 0.1 N = npts * binwidth xmin, xmax = 0.0, 3.0 pdf = F(target) print("pdf(1): %s" % pdf(1)) data = gendata(target, xmin, xmax, npts) pylab.plot(data[1:int(N)],0*data[1:int(N)],'k.') pylab.title('Samples drawn from density to be estimated.') try: show() except ImportError: pylab.show() pylab.clf() binsc, histo = histogram(data, binwidth, xmin,xmax) print("binsc: %s" % binsc) print("count: %s" % histo) print("ncount: %s" % (histo//N)) print("exact : %s" % pdf(binsc)) print("now with DE...") myCF = lorentzian.CostFactory2(binsc, histo//N, ND) sol, steps = de_solve(myCF)