@@ -108,7 +108,7 @@ typeof(transitions)
108
108
109
109
In Turing.jl, initial parameters for MCMC sampling can be specified using the ` initial_params ` keyword argument.
110
110
111
- For single-chain sampling, the AbstractMCMC interface generally expects that you provide a completely flattened vector of parameters.
111
+ For ** single-chain sampling** , the AbstractMCMC interface generally expects that you provide a completely flattened vector of parameters.
112
112
113
113
``` {julia}
114
114
chn = sample(demo_model(), MH(), 5; initial_params=[1.0, -5.0])
@@ -148,6 +148,17 @@ init_x, init_y = rand(LKJCholesky(3, 0.5)), rand(MvNormal(zeros(3), I))
148
148
chn = sample(demo_complex(), MH(), 5; initial_params=(x=init_x, y=init_y));
149
149
```
150
150
151
+ For ** multiple-chain sampling** , the ` initial_params ` keyword argument should be a vector with length equal to the number of chains being sampled.
152
+ Each element of this vector should be the initial parameters for the corresponding chain, as described above.
153
+ Thus, for example, a vector of vectors, or a vector of ` NamedTuple ` s, can be used.
154
+ If you want to use the same initial parameters for all chains, you can use ` fill ` :
155
+
156
+ ``` {julia}
157
+ initial_params = fill((x=1.0, y=-5.0), 3)
158
+ chn = sample(demo_model(), MH(), MCMCThreads(), 5, 3; initial_params=initial_params)
159
+ chn[:x][1,:], chn[:y][1,:]
160
+ ```
161
+
151
162
::: {.callout-important}
152
163
## Upcoming changes in Turing v0.41
153
164
0 commit comments