Skip to content

DynamicPPL documentation is incorrect #2661

@vboussange

Description

@vboussange

Minimal working example

using DynamicPPL

# Create the model function.
function gdemo2(model, varinfo, context, x)
    # Assume s² has an InverseGamma distribution.
    s², varinfo = DynamicPPL.tilde_assume!!(
        context, InverseGamma(2, 3), @varname(s²), varinfo
    )

    # Assume m has a Normal distribution.
    m, varinfo = DynamicPPL.tilde_assume!!(
        context, Normal(0, sqrt(s²)), @varname(m), varinfo
    )

    # Observe each value of x[i] according to a Normal distribution.
    for i in eachindex(x)
        _retval, varinfo = DynamicPPL.tilde_observe!!(
            context, Normal(m, sqrt(s²)), x[i], @varname(x[i]), varinfo
        )
    end

    # The final return statement should comprise both the original return
    # value and the updated varinfo.
    return nothing, varinfo
end
gdemo2(x) = DynamicPPL.Model(gdemo2, (; x))

# Instantiate a Model object with our data variables.
model2 = gdemo2([1.5, 2.0])


# Errors
chain = sample(model2, NUTS(), 1000; progress=false)

Description

Hey there, just trying to execute the code provided in https://turinglang.org/docs/developers/compiler/model-manual/ errors.

As a side note, it would be nice to

  1. Briefly explain what model is
  2. Why do we need to provide a named tuple to DynamicPPL.Model, since gdemo2 is defined with positional arguments?

Julia version info

versioninfo()
(Paste here)

Manifest

]st --manifest
(Paste here)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions