Skip to content

Commit

Permalink
Merge 74db63b into 2d632de
Browse files Browse the repository at this point in the history
  • Loading branch information
twiecki committed Dec 8, 2016
2 parents 2d632de + 74db63b commit 1d8b52d
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 40 deletions.
78 changes: 41 additions & 37 deletions pymc3/tests/test_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,26 @@ class TestStepMethods(object): # yield test doesn't work subclassing unittest.T
7.04959179e-01, 8.37863464e-01, -5.24200836e-01, 1.28261340e+00, 9.08774240e-01,
8.80566763e-01, 7.82911967e-01, 8.01843432e-01, 7.09251098e-01, 5.73803618e-01]),
HamiltonianMC: np.array([
-1.56440708e-03, -2.37766120e-03, -6.95819902e-03, -4.88882715e-03, -6.54928517e-03,
-3.38653286e-03, -1.99381372e-03, -1.25904805e-03, -2.97173572e-04, -4.67391216e-04,
-2.03821237e-03, -1.33693751e-04, -2.17293248e-03, -4.11675406e-03, -4.23091782e-03,
-7.34120851e-03, -8.43726968e-03, -7.86976139e-03, -3.89551467e-03, -3.00788956e-03,
-3.82420513e-03, -1.35604792e-03, -2.49066947e-04, 4.03633859e-04, 9.34321408e-05,
1.77722574e-03, 1.63761359e-03, 2.86208401e-03, -1.72243038e-04, 1.86863525e-03,
1.76740215e-03, 1.79169049e-03, 1.07164602e-03, 1.41264547e-03, 2.49563456e-03,
1.76639216e-03, 3.01570589e-03, 1.44186424e-04, 1.45073846e-03, 2.95031617e-04,
-1.28811479e-04, -7.35945905e-04, -6.00689088e-04, 2.75468405e-04, 1.05245800e-03,
1.18892307e-03, 6.01165842e-04, 1.21016955e-03, -2.06751271e-03, -8.41426458e-04,
6.09905557e-04, 2.92765303e-03, 4.15216348e-03, 2.71863268e-03, 3.42922082e-03,
7.53890188e-03, 7.97507867e-03, 8.27371677e-03, 9.77811135e-03, 9.99705714e-03,
1.13996054e-02, 1.15745874e-02, 1.08182152e-02, 1.08277279e-02, 9.32254191e-03,
8.59914793e-03, 8.43927425e-03, 1.01570101e-02, 9.74607039e-03, 9.82868496e-03,
1.01745777e-02, 1.19312194e-02, 1.53760522e-02, 1.38691940e-02, 1.40131760e-02,
1.46184561e-02, 1.74382675e-02, 1.84241543e-02, 2.06913002e-02, 1.83520531e-02,
2.03072531e-02, 1.72912752e-02, 1.38959101e-02, 1.21933473e-02, 1.05084488e-02,
9.00532336e-03, 9.25863206e-03, 1.23618461e-02, 1.20207293e-02, 1.09334818e-02,
1.16528011e-02, 1.29967126e-02, 1.38940942e-02, 1.11408833e-02, 1.09263348e-02,
1.06521352e-02, 1.01622526e-02, 1.21998547e-02, 1.00880470e-02, 9.94787795e-03]),
-0.74925631, -0.2566773 , -2.12480977, 1.64328926, -1.39315913,
2.04200003, 0.00706711, 0.34240498, 0.44276674, -0.21368043,
-0.76398723, 1.19280082, -1.43030242, -0.44896107, 0.0547087 ,
-1.72170938, -0.20443956, 0.35432546, 1.77695096, -0.31053636,
-0.26729283, 1.26450201, 0.17049917, 0.27953939, -0.24185153,
0.95617117, -0.45707061, 0.75837366, -1.73391277, 1.63331612,
-0.68426038, 0.20499991, -0.43866983, 0.31080195, 0.47104548,
-0.50331753, 0.7821196 , -1.7544931 , 1.24106497, -1.0152971 ,
-0.01949091, -0.33151479, 0.19138253, 0.40349184, 0.31694823,
-0.01508142, -0.31330951, 0.40874228, 0.40874228, 0.58078882,
0.68378375, 0.84142914, 0.44756075, -0.87297183, 0.59695222,
1.96161733, -0.37126652, 0.27552912, 0.74547583, -0.16172925,
0.79969568, -0.20501522, -0.36181518, 0.13114261, -0.8461323 ,
-0.07749079, -0.07013026, 0.88022116, -0.5546825 , 0.25232708,
0.09483573, 0.84910913, 1.33348018, -1.1971401 , 0.49203123,
0.22365435, 1.3801812 , 0.06885929, 1.07115053, -1.52225141,
1.50179721, -2.01528399, -1.31610679, -0.32298834, -0.80630885,
-0.6828592 , 0.2897919 , 1.64608125, -0.71793662, -0.5233058 ,
0.53549836, 0.61119221, 0.24235732, -1.3940593 , 0.28380114,
-0.22629978, -0.19318957, 1.12543101, -1.40328285, 0.21054137]),
Metropolis: np.array([
1.62434536, 1.01258895, 0.4844172, -0.58855142, 1.15626034, 0.39505344, 1.85716138,
-0.20297933, -0.20297933, -0.20297933, -0.20297933, -1.08083775, -1.08083775,
Expand All @@ -76,22 +76,26 @@ class TestStepMethods(object): # yield test doesn't work subclassing unittest.T
2.18960348, 2.18960348, 2.63096792, 2.53081269, 2.5482221, 1.42620337, 0.90910891,
-0.08791792, 0.40729341, 0.23259025, 0.23259025, 0.23259025, 2.76091595, 2.51228118]),
NUTS: np.array([
0.68819657, 0.1767813, -0.59467679, -0.64216066, 1.63681405, 2.13404699, 0.03126563,
0.31817152, 0.31817152, 0.40191527, 0.40191527, 0.99220141, 0.93036804, -0.41228181,
-1.80465851, -1.70577291, 0.19406438, 0.19406438, -0.03965181, -0.76135744,
0.70023098, 1.07183677, 1.07183677, 0.2829979, 1.13524135, -0.26461224,
-0.39442329, -1.04109657, 0.79971205, 0.79971205, 0.96839778, 0.91868626,
0.19468837, 0.19468837, -0.67755668, -0.67755668, -0.43722432, 0.12072881,
0.6267432, 0.6861771, 0.4669198, 0.4669198, -0.08143768, 0.27691068, 0.11510718,
2.29821426, 2.18308403, 1.16618069, -0.45615197, -0.45615197, -0.37076172,
-0.37076172, -0.38889599, 0.36200553, -0.55179735, -0.55179735, -0.18946703,
1.11552335, 0.98985795, 0.98985795, 1.00313687, -0.18458164, 0.44025584, 0.97610126,
-0.1558578, -0.1558578, -0.01247235, -0.08303131, 0.52019377, -1.52329796,
-1.72856248, -1.19049049, -1.19049049, -0.8651521, -0.36421118, -0.40590409,
-0.78925074, -0.53960924, -0.53960924, 0.1069186, 0.40849997, 0.1560954,
0.35461684, 0.35461684, -0.83935418, -0.85295353, -0.13990269, -0.1412904,
-0.1412904, -0.30071575, -0.296461, 0.06540186, -0.15145479, -0.15145479,
-0.21406771, -0.21533218, 0.06833495, 0.06833495, -0.18763595, 0.34138144]),
1.11832371, 1.11832371, 0.6296164 , -1.88725852, -0.28085593,
-0.28085593, 0.51246481, 0.51246481, 0.51524239, -1.07479086,
-1.42956404, -1.42956404, 0.236747 , -1.04721507, -0.9716711 ,
-0.9716711 , -0.65903886, 1.392075 , 0.97569367, 0.16332534,
0.16332534, -0.36465255, 1.4513665 , 0.60044829, 0.60044829,
-0.7582248 , -0.81863678, -0.8432519 , 0.4756505 , -1.8618275 ,
-1.28026218, -1.28026218, -1.39438141, -1.33699454, 1.65436385,
1.18307331, 1.18307331, -1.02586036, -0.49676467, -0.17723852,
-0.17723852, -0.46433406, 0.80562527, 0.0872473 , 0.0872473 ,
-0.5121292 , 0.2457691 , 0.2457691 , -0.28227229, -0.56863496,
-0.13361197, 0.40085491, -0.34774478, -0.34774478, -0.49552973,
-0.50378818, 0.26151237, 0.26151237, -0.3271885 , -0.33567672,
0.9339671 , 0.92457538, 0.92457538, 0.92079262, 0.07603108,
0.53798844, 0.5509594 , -0.10204449, -0.10204449, -0.27679836,
0.29559731, -0.63318597, 0.50441029, 0.50441029, -0.64408839,
0.85784078, 0.83528853, 0.32389337, 0.32389337, 0.32371787,
0.45515893, 0.42012555, 0.42012555, -0.02036946, -0.1275346 ,
0.1818874 , 1.28333928, 0.92705793, 0.92705793, 0.42301906,
1.97444363, 2.12202997, 1.79560373, 1.79560373, 1.658178 ,
1.64034201, 2.01737179, 1.45213152, 1.45213152, 1.4536979 ]),
}

def test_sample_exact(self):
Expand Down Expand Up @@ -124,7 +128,7 @@ def check_trace(self, step_method):
with Model():
Normal('x', mu=0, sd=1)
trace = sample(n_steps, step=step_method(), random_seed=1)

print(repr(trace.get_values('x')))
if not benchmarking:
assert_array_almost_equal(trace.get_values('x'), self.master_samples[step_method])

Expand Down
6 changes: 3 additions & 3 deletions pymc3/tuning/scaling.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def find_hessian_diag(point, vars=None, model=None):
return H(Point(point, model=model))


def guess_scaling(point, vars=None, model=None, scaling_bound=1e-3):
def guess_scaling(point, vars=None, model=None, scaling_bound=1e-8):
model = modelcontext(model)
try:
h = find_hessian_diag(point, vars, model=model)
Expand All @@ -123,10 +123,10 @@ def adjust_scaling(s, scaling_bound):
return eig_recompose(val, vec)


def adjust_precision(tau, scaling_bound=1e-3):
def adjust_precision(tau, scaling_bound=1e-8):
mag = sqrt(abs(tau))

bounded = bound(log(mag), log(1/scaling_bound), log(scaling_bound))
bounded = bound(log(mag), log(scaling_bound), log(1./scaling_bound))
return exp(bounded)**2


Expand Down

0 comments on commit 1d8b52d

Please sign in to comment.