Skip to content

Commit 915ea76

Browse files
authored
Merge pull request #262 from bangerth/comments
Fix a bug.
2 parents 3046cdd + b7a5ce5 commit 915ea76

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

include/sampleflow/producers/differential_evaluation_mh.impl.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,12 +233,14 @@ namespace SampleFlow
233233
b_dist(0, n_chains - 3);
234234

235235
typename std::vector<OutputType>::size_type b = b_dist(rng);
236+
if (b >= std::min<typename std::vector<OutputType>::size_type>(a, chain))
237+
++b;
236238
if (b >= std::max(a, chain))
237-
b += 2;
238-
else if (b >= std::min<typename std::vector<OutputType>::size_type>(a, chain))
239-
b += 1;
239+
++b;
240240
const OutputType trial_b = current_samples[b];
241241

242+
assert (a!=b);
243+
242244
// Combine trial a and trial b
243245
const OutputType crossover_result = crossover(current_samples[chain], trial_a, trial_b);
244246
trial_sample_and_ratio = propose_sample(crossover_result);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Mean value = 1.9881
1+
Mean value = 1.98196

0 commit comments

Comments
 (0)