Skip to content

Commit

Permalink
Merge pull request #679 from TuringLang/mt/fix_internals_docs
Browse files Browse the repository at this point in the history
Fix internals example in advanced docs
  • Loading branch information
cpfiffer authored Feb 9, 2019
2 parents cb01a0d + cbb1a10 commit 0d5cf23
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions docs/src/_docs/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ mf(vi, sampler, model) = begin
if isdefined(model.data, :x)
x = model.data.x
else # x is a parameter
x = Vector{Real}(undef, 2)
x = model.defaults.x
end

# Assume s has an InverseGamma distribution.
Expand Down Expand Up @@ -118,8 +118,11 @@ mf(vi, sampler, model) = begin
end
end

# Define the default value for x when missing
defaults = (x = Vector{Real}(undef, 2),)

# Instantiate a Model object.
model = Turing.Model{Tuple{:s, :m}, Tuple{:x}}(mf, data)
model = Turing.Model{Tuple{:s, :m}, Tuple{:x}}(mf, data, defaults)

# Sample the model.
chain = sample(model, HMC(1000, 0.1, 5))
Expand Down

0 comments on commit 0d5cf23

Please sign in to comment.