You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/api.md
+22-9Lines changed: 22 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -92,32 +92,45 @@ To ensure that sampling multiple chains "just works" when sampling of a single c
92
92
93
93
## Progress logging
94
94
95
-
The default value for the `progress` keyword argument is `AbstractMCMC.PROGRESS[]`, which is always set to `true` unless modified with `AbstractMCMC.setprogress!`.
96
-
For example, `setprogress!(false)` will disable all progress logging.
95
+
Progress logging is controlled in one of two ways:
97
96
98
-
```@docs
99
-
AbstractMCMC.setprogress!
100
-
```
97
+
- by passing the `progress` keyword argument to the `sample(...)` function, or
98
+
- by globally changing the defaults with `AbstractMCMC.setprogress!` and `AbstractMCMC.setmaxchainsprogress!`.
99
+
100
+
### `progress` keyword argument
101
101
102
102
For single-chain sampling (i.e., `sample([rng,] model, sampler, N)`), as well as multiple-chain sampling with `MCMCSerial`, the `progress` keyword argument should be a `Bool`.
103
103
104
104
For multiple-chain sampling using `MCMCThreads`, there are several, more detailed, options:
105
105
106
-
-`:perchain`: create one progress bar per chain being sampled
106
+
-`:perchain`: create one progress bar per chain being sampled, plus one progress bar tracking the number of chains
107
107
-`:overall`: create one progress bar for the overall sampling process, which tracks the percentage of samples that have been sampled across all chains
108
108
-`:none`: do not create any progress bar
109
109
-`true` (the default): use `perchain` for 10 or fewer chains, and `overall` for more than 10 chains
110
110
-`false`: same as `none`, i.e. no progress bar
111
111
112
-
The threshold of 10 chains can be changed using `AbstractMCMC.setmaxchainsprogress!(N)`, which will cause `MCMCThreads` to use `:perchain` for `N` or fewer chains, and `:overall` for more than `N` chains.
113
-
Thus, for example, if you _always_ want to use `:overall`, you can call `AbstractMCMC.setmaxchainsprogress!(0)`.
114
-
115
112
Multiple-chain sampling using `MCMCDistributed` behaves the same as `MCMCThreads`, except that `:perchain` is not (yet?) implemented.
116
113
So, `true` always corresponds to `:overall`, and `false` corresponds to `:none`.
117
114
118
115
!!! warning "Do not override the `progress` keyword argument"
119
116
If you are implementing your own methods for `sample(...)`, you should make sure to not override the `progress` keyword argument if you want progress logging in multi-chain sampling to work correctly, as the multi-chain `sample()` call makes sure to specifically pass custom values of `progress` to the single-chain calls.
120
117
118
+
### Global settings
119
+
120
+
If you are sampling multiple times and would like to change the default behaviour, you can use these functions to control progress logging globally:
121
+
122
+
```@docs
123
+
AbstractMCMC.setprogress!
124
+
AbstractMCMC.setmaxchainsprogress!
125
+
```
126
+
127
+
`setprogress!` is more general, and applies to all types of sampling (both single- and multiple-chain).
128
+
It only takes a boolean argument, which switches progress logging on or off.
129
+
For example, `setprogress!(false)` will disable all progress logging.
130
+
131
+
On the other hand, `setmaxchainsprogress!` is specific to multiple-chain sampling, and allows you to set the threshold for when to switch from `:perchain` to `:overall` progress logging.
132
+
Thus, for example, if you want to keep progress logging on but _always_ want to use `:overall`, you can set `AbstractMCMC.setmaxchainsprogress!(0)`.
133
+
121
134
## Chains
122
135
123
136
The `chain_type` keyword argument allows to set the type of the returned chain. A common
0 commit comments