-
Notifications
You must be signed in to change notification settings - Fork 4
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
Variable Elimination #238
base: master
Are you sure you want to change the base?
Variable Elimination #238
Conversation
Pull Request Test Coverage Report for Build 11942739972Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
BridgeStan not found at location specified by $BRIDGESTAN environment variable, downloading version 2.5.0 to /home/runner/.bridgestan/bridgestan-2.5.0
|
for (k, v) in evidence | ||
node_id = bn.names_to_ids[k] | ||
dist_idx = findfirst(id -> id == node_id, bn.stochastic_ids) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
|
||
@testset "Marginalization with Mixed Variables" begin | ||
bn = BayesianNetwork{Symbol}() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
|
||
# X1 ~ Normal(0, 1) | ||
add_stochastic_vertex!(bn, :X1, Normal(0, 1), false) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
|
||
# X2 ~ Bernoulli(0.7) [using Categorical with 2 categories] | ||
add_stochastic_vertex!(bn, :X2, Categorical([0.3, 0.7]), false) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
# X3 ~ Normal(μ = 2*X2, σ = 1) | ||
add_stochastic_vertex!(bn, :X3, Normal(0, 1), false) | ||
add_edge!(bn, :X2, :X3) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
# Umbrella Sales (X3) ~ Normal(μ(X2), 1) | ||
# μ = 2 if no rain (X2=0), μ = 10 if rain (X2=1) | ||
add_stochastic_vertex!(bn, :X3, Normal(0, 1), false) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
add_stochastic_vertex!(bn, :X3, Normal(0, 1), false) | ||
|
||
add_edge!(bn, :X2, :X3) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
@test result1 > 0 | ||
println("P(X3|X1) = ", result1) | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
@test 0 ≤ result ≤ 1 | ||
@test isapprox(result, 0.3, atol=0.1) # Should be close to P(X2=0)=0.3 | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
result_rain = variable_elimination(bn, :X3, Dict(:X2 => 1)) | ||
@test result_rain isa Number | ||
@test result_rain > 0 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
No description provided.