Skip to content

Commit 3b6351f

Browse files
torfjeldeyebai
andauthored
Fixes for constructor docstrings (#347)
* docstring fixes for constructors * fixed docs * minor fix for docs * Update Project.toml --------- Co-authored-by: Hong Ge <[email protected]>
1 parent eb9b2e0 commit 3b6351f

File tree

3 files changed

+21
-36
lines changed

3 files changed

+21
-36
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "AdvancedHMC"
22
uuid = "0bf59076-c3b1-5ca4-86bd-e02cd72cde3d"
3-
version = "0.5.3"
3+
version = "0.5.4"
44

55
[deps]
66
AbstractMCMC = "80f14c24-f653-4e6a-9b94-39d6b0f70001"

README.md

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -212,22 +212,23 @@ In the previous examples, we built the sampler by manually specifying the integr
212212
Moreover, there's some flexibility in how these samplers can be initialized.
213213
For example, a user can initialize a NUTS (HMC and HMCDA) sampler with their own metrics and integrators.
214214
This can be done as follows:
215-
```julia
216-
nuts = NUTS(δ, metric = :diagonal) #metric = DiagEuclideanMetric(D) (Default!)
217-
nuts = NUTS(δ, metric = :unit) #metric = UnitEuclideanMetric(D)
218-
nuts = NUTS(δ, metric = :dense) #metric = DenseEuclideanMetric(D)
219-
# Provide your own AbstractMetric
220-
metric = DiagEuclideanMetric(10)
221-
nuts = NUTS(δ, metric = metric)
222-
223-
nuts = NUTS(δ, integrator = :leapfrog) #integrator = Leapfrog(ϵ) (Default!)
224-
nuts = NUTS(δ, integrator = :jitteredleapfrog) #integrator = JitteredLeapfrog(ϵ, 0.1ϵ)
225-
nuts = NUTS(δ, integrator = :temperedleapfrog) #integrator = TemperedLeapfrog(ϵ, 1.0)
226-
227-
# Provide your own AbstractIntegrator
228-
integrator = JitteredLeapfrog(0.1, 0.2)
229-
nuts = NUTS(δ, integrator = integrator)
230-
```
215+
216+
```julia
217+
nuts = NUTS(δ, metric = :diagonal) #metric = DiagEuclideanMetric(D) (Default!)
218+
nuts = NUTS(δ, metric = :unit) #metric = UnitEuclideanMetric(D)
219+
nuts = NUTS(δ, metric = :dense) #metric = DenseEuclideanMetric(D)
220+
# Provide your own AbstractMetric
221+
metric = DiagEuclideanMetric(10)
222+
nuts = NUTS(δ, metric = metric)
223+
224+
nuts = NUTS(δ, integrator = :leapfrog) #integrator = Leapfrog(ϵ) (Default!)
225+
nuts = NUTS(δ, integrator = :jitteredleapfrog) #integrator = JitteredLeapfrog(ϵ, 0.1ϵ)
226+
nuts = NUTS(δ, integrator = :temperedleapfrog) #integrator = TemperedLeapfrog(ϵ, 1.0)
227+
228+
# Provide your own AbstractIntegrator
229+
integrator = JitteredLeapfrog(0.1, 0.2)
230+
nuts = NUTS(δ, integrator = integrator)
231+
```
231232

232233
### GPU Sampling with CUDA
233234

src/constructors.jl

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,13 @@ sampler_eltype(sampler::HMCSampler) = eltype(sampler.metric)
6767
### NUTS ###
6868
############
6969
"""
70-
NUTS(δ::Real; max_depth::Int=10, Δ_max::Real=1000, init_ϵ::Real=0, integrator = :leapfrog, metric = :diagonal)
70+
NUTS(δ::Real; max_depth::Int=10, Δ_max::Real=1000, integrator = :leapfrog, metric = :diagonal)
7171
7272
No-U-Turn Sampler (NUTS) sampler.
7373
7474
# Fields
7575
7676
$(FIELDS)
77-
78-
# Usage:
79-
80-
```julia
81-
NUTS(δ=0.65) # Use target accept ratio 0.65.
82-
```
8377
"""
8478
struct NUTS{T<:Real,I<:Union{Symbol,AbstractIntegrator},M<:Union{Symbol,AbstractMetric}} <:
8579
AbstractHMCSampler
@@ -113,12 +107,6 @@ Hamiltonian Monte Carlo sampler with static trajectory.
113107
# Fields
114108
115109
$(FIELDS)
116-
117-
# Usage:
118-
119-
```julia
120-
HMC(10, integrator = Leapfrog(0.05), metric = :diagonal)
121-
```
122110
"""
123111
struct HMC{I<:Union{Symbol,AbstractIntegrator},M<:Union{Symbol,AbstractMetric}} <:
124112
AbstractHMCSampler
@@ -140,19 +128,15 @@ sampler_eltype(sampler::HMC) = determine_sampler_eltype(sampler.metric, sampler.
140128
### HMCDA ###
141129
#############
142130
"""
143-
HMCDA(δ::Real, λ::Real; ϵ::Real=0, integrator = :leapfrog, metric = :diagonal)
131+
HMCDA(δ::Real, λ::Real, integrator = :leapfrog, metric = :diagonal)
144132
145133
Hamiltonian Monte Carlo sampler with Dual Averaging algorithm.
146134
147135
# Fields
148136
149137
$(FIELDS)
150138
151-
# Usage:
152-
153-
```julia
154-
HMCDA(δ=0.65, λ=0.3)
155-
```
139+
# Notes
156140
157141
For more information, please view the following paper ([arXiv link](https://arxiv.org/abs/1111.4246)):
158142

0 commit comments

Comments
 (0)