Skip to content

Commit 3046cdd

Browse files
authored
Merge pull request #261 from bangerth/comments
Leave some comments.
2 parents 6a3c721 + 8478aaf commit 3046cdd

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

include/sampleflow/producers/differential_evaluation_mh.impl.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,16 +211,24 @@ namespace SampleFlow
211211
&&
212212
(generation > 0))
213213
{
214-
// Pick one of the other chains from which we want to draw from:
214+
// Pick one of the other chains from which we want to draw:
215215
std::uniform_int_distribution<typename std::vector<OutputType>::size_type>
216216
a_dist(0, n_chains - 2);
217217

218+
// Pick one chain with index 'a', just not the current one. We do this by
219+
// drawing from [0...n_chains-2] and mapping that onto the union of the
220+
// intervals [0...chain) + (chain...n_chains-1].
218221
typename std::vector<OutputType>::size_type a = a_dist(rng);
219222
if (a >= chain)
220223
a += 1;
221224
const OutputType trial_a = current_samples[a];
222225

223-
// Then the other chain to draw from:
226+
// Then the other chain to draw from, but make sure it's not the same as
227+
// 'chain' or 'a'. We do this by drawing from [0...n_chains-3] and mapping
228+
// that onto the union of the intervals
229+
// [0...x) + (x...y) + (y...n_chains-1]
230+
// where x=min(chain,a), y=max(chain,c) are the two points we want
231+
// to avoid.
224232
std::uniform_int_distribution<typename std::vector<OutputType>::size_type>
225233
b_dist(0, n_chains - 3);
226234

0 commit comments

Comments
 (0)