Skip to content

Commit af8cab2

Browse files
Align DEMetropolis defaults with literature recommendations (#6488)
* Changed DEMetropolis and DEMetropolisZ sampler defaults to NormalProposal and tune scaling Co-authored-by: Michael Osthege <[email protected]>
1 parent 65c1c68 commit af8cab2

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

pymc/step_methods/metropolis.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -707,11 +707,11 @@ class DEMetropolis(PopulationArrayStepShared):
707707
Some measure of variance to parameterize proposal distribution
708708
proposal_dist: function
709709
Function that returns zero-mean deviates when parameterized with
710-
S (and n). Defaults to Uniform(-S,+S).
710+
S (and n). Defaults to NormalProposal(S).
711711
scaling: scalar or array
712712
Initial scale factor for epsilon. Defaults to 0.001
713713
tune: str
714-
Which hyperparameter to tune. Defaults to None, but can also be 'scaling' or 'lambda'.
714+
Which hyperparameter to tune. Defaults to 'scaling', but can also be 'lambda' or None.
715715
tune_interval: int
716716
The frequency of tuning. Defaults to 100 iterations.
717717
model: PyMC Model
@@ -748,7 +748,7 @@ def __init__(
748748
proposal_dist=None,
749749
lamb=None,
750750
scaling=0.001,
751-
tune=None,
751+
tune: Optional[str] = "scaling",
752752
tune_interval=100,
753753
model=None,
754754
mode=None,
@@ -770,7 +770,7 @@ def __init__(
770770
if proposal_dist is not None:
771771
self.proposal_dist = proposal_dist(S)
772772
else:
773-
self.proposal_dist = UniformProposal(S)
773+
self.proposal_dist = NormalProposal(S)
774774

775775
self.scaling = np.atleast_1d(scaling).astype("d")
776776
if lamb is None:
@@ -851,11 +851,11 @@ class DEMetropolisZ(ArrayStepShared):
851851
Some measure of variance to parameterize proposal distribution
852852
proposal_dist: function
853853
Function that returns zero-mean deviates when parameterized with
854-
S (and n). Defaults to Uniform(-S,+S).
854+
S (and n). Defaults to NormalProposal(S).
855855
scaling: scalar or array
856856
Initial scale factor for epsilon. Defaults to 0.001
857857
tune: str
858-
Which hyperparameter to tune. Defaults to 'lambda', but can also be 'scaling' or None.
858+
Which hyperparameter to tune. Defaults to 'scaling', but can also be 'lambda' or None.
859859
tune_interval: int
860860
The frequency of tuning. Defaults to 100 iterations.
861861
tune_drop_fraction: float
@@ -869,7 +869,7 @@ class DEMetropolisZ(ArrayStepShared):
869869
870870
References
871871
----------
872-
.. [Braak2006] Cajo C.F. ter Braak (2006).
872+
.. [Braak2008] Cajo C.F. ter Braak (2008).
873873
Differential Evolution Markov Chain with snooker updater and fewer chains.
874874
Statistics and Computing
875875
`link <https://doi.org/10.1007/s11222-008-9104-9>`__
@@ -895,7 +895,7 @@ def __init__(
895895
proposal_dist=None,
896896
lamb=None,
897897
scaling=0.001,
898-
tune="lambda",
898+
tune: Optional[str] = "scaling",
899899
tune_interval=100,
900900
tune_drop_fraction: float = 0.9,
901901
model=None,
@@ -917,7 +917,7 @@ def __init__(
917917
if proposal_dist is not None:
918918
self.proposal_dist = proposal_dist(S)
919919
else:
920-
self.proposal_dist = UniformProposal(S)
920+
self.proposal_dist = NormalProposal(S)
921921

922922
self.scaling = np.atleast_1d(scaling).astype("d")
923923
if lamb is None:

pymc/tests/step_methods/test_metropolis.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ def test_demcmc_tune_parameter(self):
138138
pm.Normal("n", mu=0, sigma=1, size=(2, 3))
139139

140140
step = DEMetropolis()
141+
assert step.tune == "scaling"
142+
143+
step = DEMetropolis(tune=None)
141144
assert step.tune is None
142145

143146
step = DEMetropolis(tune="scaling")

0 commit comments

Comments
 (0)