def get_problem(): # return gauss_model.get_problem(dim=dim, n=n) return banana_model.get_problem(dim=dim, a=20, n0=1000, n=n)
import banana_model import dp_barker import numpy as np import matplotlib.pyplot as plt np.random.seed(4673228) dim = 2 problem = banana_model.get_problem(dim=dim, a=20, n0=1000, n=100000) n, data_dim = problem.data.shape epsilon = 4 delta = 0.1 / n params = dp_barker.BarkerParams(prop_sigma=np.repeat(0.008 * 15, 2), batch_size=1300) res = dp_barker.dp_barker(problem, problem.theta0, epsilon, delta, params) print("DP mcmc acceptance: {}".format(res.acceptance)) print(f"Clipped: {res.clipped_r}") mean_error = res.mean_error cov_error = res.cov_error mmd = res.mmd print(f"Mean error: {mean_error}") print(f"Cov error: {cov_error}") print(f"MMD: {mmd}") fig, axes = plt.subplots(dim) for i in range(dim): axes[i].plot(res.chain[:, i]) plt.show()
import numpy as np import scipy.stats as stats import pandas as pd import banana_model import mmd import argparse import clipping parser = argparse.ArgumentParser() parser.add_argument("clip_bound", type=float) parser.add_argument("dim", type=int) parser.add_argument("index", type=int) parser.add_argument("output", type=str) args = parser.parse_args() problem = banana_model.get_problem(dim=args.dim, a=20, n0=None, n=100000) n, data_dim = problem.data.shape dim = args.dim iters = 500 eta = 0.001 L = 15 mass = np.ones(dim) mass[1] = 0.5 if dim > 2: mass[2:] = 0.4 clip_bound = args.clip_bound theta0 = np.zeros(dim) theta0[1] = 3 # Set the seed for the starting points only based on index
def get_problem(self): return banana_model.get_problem(self.dim, self.n0, self.a, self.n)