Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making use of Symbolics.jl/SymbolicUtils.jl #234

Closed
wants to merge 13 commits into from
4 changes: 1 addition & 3 deletions src/compiler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,7 @@ variables.
"""
function generate_tilde(left, right)
@gensym tmpright
top = [:($tmpright = $right),
:($tmpright isa Union{$Distribution,AbstractVector{<:$Distribution}}
|| throw(ArgumentError($DISTMSG)))]
top = [:($tmpright = $right),]

if left isa Symbol || left isa Expr
@gensym out vn inds isassumption
Expand Down
6 changes: 3 additions & 3 deletions src/context_implementations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ end
function assume(
rng,
spl::Union{SampleFromPrior,SampleFromUniform},
dist::Distribution,
dist,
vn::VarName,
vi,
)
Expand All @@ -144,12 +144,12 @@ end

function observe(
spl::Union{SampleFromPrior, SampleFromUniform},
dist::Distribution,
dist,
value,
vi,
)
increment_num_produce!(vi)
return Distributions.loglikelihood(dist, value)
return sum(Distributions.logpdf(dist, value))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is left-over from some earlier experimentation I did. We should make loglikelihood a primitive, and then work from there I think.

end

# .~ functions
Expand Down
5 changes: 5 additions & 0 deletions src/varinfo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ function VarInfo(old_vi::TypedVarInfo, spl, x::AbstractVector)
VarInfo(md, Base.RefValue{eltype(x)}(getlogp(old_vi)), Ref(get_num_produce(old_vi)))
end

function VarInfo(old_vi::TypedVarInfo, spl, x::AbstractVector, lp::T) where {T}
md = newmetadata(old_vi.metadata, Val(getspace(spl)), x)
VarInfo(md, Base.RefValue{T}(lp), Ref(get_num_produce(old_vi)))
torfjelde marked this conversation as resolved.
Show resolved Hide resolved
end

function VarInfo(
rng::Random.AbstractRNG,
model::Model,
Expand Down