Skip to content

Commit

Permalink
Some cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
laynep committed Sep 2, 2016
1 parent b1a6789 commit 4f80f73
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions emulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,10 @@ def get_x(ndim):
#np.random.normal(0.0,60.1),
#np.random.normal(1.0,2.1)])

else:
raise RuntimeError('This number of dimensions has'+
' not been implemented for testing yet.')

if ndim==1:
Xtrain = get_x(ndim)
xlist = np.linspace(-3.0,3.0,11)
Expand All @@ -468,7 +472,6 @@ def get_x(ndim):

######################
######################
import emcee

#Toy likelihood
@emulator
Expand All @@ -483,22 +486,19 @@ def loglike(x):
######################
######################


p0 = np.array([get_x(ndim) for _ in xrange(nwalkers)])
sampler = emcee.EnsembleSampler(nwalkers, ndim, loglike, threads=nthreads)



for x in xlist:
print "x", x
print "val, err", loglike(x)

#Let's see if this works with a Monte Carlo method
import emcee

p0 = np.array([get_x(ndim) for _ in xrange(nwalkers)])
sampler = emcee.EnsembleSampler(nwalkers, ndim, loglike, threads=nthreads)

for result in sampler.sample(p0, iterations=niterations, storechain=False):
fname = open('test.txt', "a")

#result[0] = chain
#result[1] = like

for elmn in zip(result[1],result[0]):
fname.write("%s " % str(elmn[0]))
for k in list(elmn[1]):
Expand All @@ -508,11 +508,6 @@ def loglike(x):
print "n exact evals:", loglike.nexact
print "n emul evals:", loglike.nemul

sys.exit()





if __name__=="__main__":
main()

0 comments on commit 4f80f73

Please sign in to comment.