minor: but i'm on the verge of implementing the cubic error term for 3D
This commit is contained in:
parent
a1c88a186e
commit
c5adab295b
@ -3,44 +3,67 @@
|
|||||||
import sys
|
import sys
|
||||||
from grid.DD import random_grid
|
from grid.DD import random_grid
|
||||||
from baker import get_phis, run_baker
|
from baker import get_phis, run_baker
|
||||||
from baker.tools import exact_func, smberror, improved_answer
|
from baker.tools import exact_func, smberror, improved_answer, smblog
|
||||||
from glob import glob
|
from glob import glob
|
||||||
from os import remove
|
from os import remove
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
|
import pylab
|
||||||
|
|
||||||
|
def draw_gb(bad, good):
|
||||||
|
pylab.xlabel('total runs')
|
||||||
|
pylab.ylabel('count')
|
||||||
|
pylab.grid(True)
|
||||||
|
pylab.plot(bad)
|
||||||
|
pylab.plot(good)
|
||||||
|
pylab.legend(('bad', 'good'))
|
||||||
|
|
||||||
|
pylab.show()
|
||||||
|
|
||||||
FILE_PREFIX='/tmp/qhull-'
|
FILE_PREFIX='/tmp/qhull-'
|
||||||
|
|
||||||
for g in glob('%s*' % FILE_PREFIX):
|
|
||||||
remove(g)
|
|
||||||
|
|
||||||
try:
|
if __name__ == '__main__':
|
||||||
total_points = int(sys.argv[1])
|
for g in glob('%s*' % FILE_PREFIX):
|
||||||
random_points = int(sys.argv[2])
|
remove(g)
|
||||||
total_tries = int(sys.argv[3])
|
|
||||||
except:
|
try:
|
||||||
print "usage: app.py [total points in random grid] [number of random points to attempt] [total attempts]"
|
total_points = int(sys.argv[1])
|
||||||
sys.exit(1)
|
random_points = int(sys.argv[2])
|
||||||
|
total_tries = int(sys.argv[3])
|
||||||
|
except:
|
||||||
|
print "usage: app.py [total points in random grid] [number of random points to attempt] [total attempts]"
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
print "total points", total_points
|
print "total points", total_points
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
d = {True: 0, False: 0}
|
d = {True: 0, False: 0}
|
||||||
for cur_try in xrange(total_tries):
|
good = []
|
||||||
g = random_grid(total_points)
|
bad = []
|
||||||
open('%s%0.3d.txt' % (FILE_PREFIX, cur_try), 'w').write(g.for_qhull())
|
for cur_try in xrange(total_tries):
|
||||||
|
g = random_grid(total_points)
|
||||||
|
open('%s%0.3d.txt' % (FILE_PREFIX, cur_try), 'w').write(g.for_qhull())
|
||||||
|
|
||||||
for i in xrange(random_points):
|
for i in xrange(random_points):
|
||||||
X = [np.random.rand(), np.random.rand()]
|
X = [np.random.rand(), np.random.rand()]
|
||||||
exact = exact_func(X)
|
exact = exact_func(X)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
answer = g.run_baker(X)
|
try:
|
||||||
d[improved_answer(answer, exact)] += 1
|
answer = g.run_baker(X)
|
||||||
except smberror as e:
|
d[improved_answer(answer, exact)] += 1
|
||||||
print e
|
except ValueError as e:
|
||||||
print d
|
smblog.error(e)
|
||||||
|
except smberror as e:
|
||||||
|
print e
|
||||||
|
print d
|
||||||
|
|
||||||
print d
|
print d
|
||||||
|
bad.append(d[False])
|
||||||
|
good.append(d[True])
|
||||||
|
|
||||||
|
draw_gb(bad = bad, good = good)
|
||||||
|
@ -10,13 +10,11 @@ from os import remove
|
|||||||
|
|
||||||
FILE_PREFIX='/tmp/qhull-'
|
FILE_PREFIX='/tmp/qhull-'
|
||||||
|
|
||||||
for g in glob('%s*' % FILE_PREFIX):
|
|
||||||
remove(g)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
verts = parse_qhull_file(sys.argv[1], verbose=True)
|
verts = parse_qhull_file(sys.argv[1], verbose=True)
|
||||||
|
X = [float(sys.argv[2]), float(sys.argv[3])]
|
||||||
except:
|
except:
|
||||||
print "usage: app.py qhullinputfile"
|
print "usage: app.py qhullinputfile X Y"
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
@ -24,8 +22,6 @@ q = [exact_func(i) for i in verts]
|
|||||||
|
|
||||||
g = grid(verts,q)
|
g = grid(verts,q)
|
||||||
|
|
||||||
X = [0.13206472640187261, 0.98644929172054607]
|
|
||||||
|
|
||||||
exact = exact_func(X)
|
exact = exact_func(X)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user