Skip to content

Commit

Permalink
benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
JakobRobnik committed Oct 12, 2023
1 parent 38f165f commit 7a59391
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/benchmarks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from benchmarks.benchmarks_mchmc import *
from sampling.sampler import Sampler
from benchmarks import german_credit
import pandas as pd



def test():

names = ['Ill-Conditioned', 'Bi-Modal', 'Rosenbrock', "Neal's Funnel", 'German Credit', 'Stochastic Volatility']
targets = [IllConditionedGaussian(100, 100.0), BiModal(), Rosenbrock(), Funnel(), german_credit.Target(), StochasticVolatility()]

def ESS(target, num_samples):
sampler = Sampler(target, integrator= 'MN')
ess= jnp.average(sampler.sample(num_samples, 12, output= 'ess'))
return ess, sampler.L / np.sqrt(target.d), sampler.eps

num_samples= [30000, 100000, 300000, 100000, 100000, 10000]

results = np.array([ESS(targets[i], num_samples[i]) for i in range(len(names))])
df = pd.DataFrame({'Target ': names, 'ESS': results[:, 0], 'alpha': results[:, 1], 'eps': results[:, 2]})
print(df)




test()

0 comments on commit 7a59391

Please sign in to comment.