Skip to content

Commit 459d8f9

Browse files
authored
Fix issue
1 parent f300c71 commit 459d8f9

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/sample.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -341,19 +341,19 @@ function mcmcsample(
341341
try
342342
for (i, _rng, seed, _model, _sampler) in zip(1:nchunks, rngs, seeds, models, samplers)
343343
Threads.@spawn begin
344+
# Seed the chunk-specific random number generator with the pre-made seed.
345+
Random.seed!(_rng, seed)
346+
344347
chainidxs = if i == nchunks
345348
((i - 1) * chunksize + 1):nchains
346349
else
347350
((i - 1) * chunksize + 1):(i * chunksize)
348351
end
349352

350-
# Seed the chunk-specific random number generator with the pre-made seed.
351-
Random.seed!(_rng, seed)
352-
353353
for chainidx in chainidxs
354354
# Sample a chain and save it to the vector.
355-
chains[i] = StatsBase.sample(_rng, _model, _sampler, N;
356-
progress = false, kwargs...)
355+
chains[chainidx] = StatsBase.sample(_rng, _model, _sampler, N;
356+
progress = false, kwargs...)
357357

358358
# Update the progress bar.
359359
progress && put!(channel, true)

0 commit comments

Comments
 (0)