Skip to content

Commit

Permalink
add some documentation improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
sunxd3 committed Oct 27, 2024
1 parent b6fcf11 commit 951dffe
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion docs/src/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,13 @@ To make it a bit easier to interact with some arbitrary sampler state, we encour
AbstractMCMC.getparams
AbstractMCMC.setparams!!
```
These methods can also be useful for implementing samplers which wraps some inner samplers, e.g. a mixture of samplers.
`getparams` and `setparams!!` provide a generic interface for interacting with the parameters of a sampler's state, regardless of how that state is represented internally. If the `model` argument is not provided, the functions will be dispatched to the implementations without the `model` argument.

This allows generic code to be written that works with any sampler implementing this interface. For example, a generic ensemble sampler could use `getparams` to extract the parameters from each of its component samplers' states, and `setparams!!` to initialize each component sampler with a different set of parameters.

The optional `model` argument to these functions allows sampler implementations to customize their behavior based on the model being used. This is useful for samplers that need to access or modify the model in order to extract or set the parameters.

These methods are particularly useful for implementing samplers which wrap some inner samplers, such as a mixture of samplers. In the next section, we will see how `getparams` and `setparams!!` can be used to implement a `MixtureSampler`.

### Example: `MixtureSampler`

Expand Down

0 comments on commit 951dffe

Please sign in to comment.